Guruji Point - Code You Want To Write

  • Home
  • Asp.Net
  • WCF
  • SQL
  • Type Script
  • AngularJS
  • Tech News
  • Blog
  • Earn Online

Tuesday, 31 October 2017

INNER JOIN Example Using Lambda Expression In C# Asp.Net

 csharp lambda expression, guruji point, Gurujipoint, inner join with lamda expression, labmda expression example     No comments   


Introduction
In this article we will learn how to use join using Lambda Expression in C#. Join example with Lambda Expression using LIST collection. 

Previous Updates
In previous articles we have learnt  Maintain state of dynamic added userConrol in asp.net using c#.Arrange Distinct Elements Of A List In Ascending Order Using LINQ 

Description:
Here i am using the List collection to store the temporary/static data. In your case may be it will the database data. 
Below is My two class just like two tables Student and Department.
static void Main(string[] args)
{
    List<Emp> liEmp = new List<Emp>();
    liEmp.Add(new Emp { EmpID = 1, EmpName = "JP" });
    liEmp.Add(new Emp { EmpID = 2, EmpName = "GurujiPoint" });
    liEmp.Add(new Emp { EmpID = 3, EmpName = "PointGuruji" });
    liEmp.Add(new Emp { EmpID = 6, EmpName = "DE" });
    liEmp.Add(new Emp { EmpID = 8, EmpName = "EF" });

    List<Dep> lstDep = new List<Dep>();
    lstDep.Add(new Dep { DepID = 1, Department = ".Net", EmpID = 1 });
    lstDep.Add(new Dep { DepID = 2, Department = "PHP", EmpID = 2 });
    lstDep.Add(new Dep { DepID = 3, Department = "ASP", EmpID = 3 });
    lstDep.Add(new Dep { DepID = 4, Department = "Android", EmpID = 4 });
    lstDep.Add(new Dep { DepID = 5, Department = "GD", EmpID = 5 });
    lstDep.Add(new Dep { DepID = 6, Department = "UI", EmpID = 6 });

//INNER JOIN Using Lambda Expression
var lamdaData = 
liEmp.Join(lstDep, emp => emp.EmpID, dep => dep.EmpID, (emp, dep) => new
{
    emp.EmpID,
    emp.EmpName,
    dep.Department
});
foreach (var data in lamdaData)
    {
        Console.WriteLine("EmpId = " + data.EmpID
                         + ",Emp Name = " + data.EmpName +
                        ",Department = " + data.Department);
    }
    Console.ReadLine();
}

Output:
 Removing duplicate records from SQL Table

EmpId = 1,Emp Name = JP,Department = .Net
EmpId = 2,Emp Name = GurujiPoint,Department = PHP
EmpId = 3,Emp Name = PointGuruji,Department = ASP
EmpId = 6,Emp Name = DE,Department = UI



  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to TwitterShare to Facebook
Newer Post Older Post Home

0 comments:

Post a comment

Facebook Updates

Guruji Point

Popular Posts

  • Base64 Encoding And Decoding In SQL Server
    Introduction In this article we will learn How to encode a string into Base64String and how to decode Base64String to string. How to crea...
  • Trigger In SQL Server - Insert Update Delete In Single Trigger With Example
    Introduction In this article we will learn what is trigger . How to manage Insert, Update and Delete operation in trigger. Insert Update ...
  • Convert DataSet To List Or GenericList Using LINQ - C#
    Introduction In this article we will learn how to convert dataset to list or convert DataSet to List of collection o generic list in c#. ...
  • Difference Between DataAdapter And DataReader In Asp.Net With Example
    Introduction In this article we will learn what is DataAdapter and DataReader. What is the difference between dataadapter and datareader....
  • Read List With In List Collection Using LINQ - Increase Application Data Performances
    Introduction In this article we will learn about how to read data from a SubList or list with in list collection. How to access sub list p...

Categories

comma seperated string in sql Comman table Expression in SQL Dynamic Grid Row IQueryable in c# Learn AngularJS row_number() and dense_rank() salary table structure. Scope_Identity() Use of indexes while loop in sql why do we need cursor why tuple used

Best Deal Here

About Us

This blog is about the Programming ,Tech News and some intresting facts related Contents. Here you can find fundamental and expert level topic of programming languages very practically related to C# , Asp.Net ,Sql-Server, JavaScript, Jquery, WebServices And also Web-Api, WCF ,WPF, Angular Js.

Contact Us

Email Us - gurujipoints@gmail.com
Contact- 8077657477

Reach Us

Copyright © Guruji Point - Code You Want To Write