Wednesday, October 9, 2013

LINQ IN SQL

LINQ - Language Integrated Query

  • Feature Introduced in Visual Studio 2008 
  • Supported from Visual Studio 2008 & later versions of visual Studio.
  • Used or Query the result set from  Objects/XML/ADO.Net (Object collection/Data Set /SQL Server/Entities/XML).
  • Using Linq 
For Querying result in our front end C# language support LINQ.

Sample Query for Linq


var q=(from item in TAA_Parcels
where item.IsDeleted==false
 select new{
                item.ParcelID,
                 item.ParcelNumber,
           }).ToList(); 
  
q.Dump();

Result Set



































INNER JOIN uisng  LINQ Query

from item in Metadatas 
 join item1 in BusinessRules on item.DatabaseID equals item1.DatabaseID
where item.DatabaseID == 1 orderby item.ReportTypeID 
select new
{
item.MetadataID,
item1.RuleName,
item.ReportTypeID,
item1.FormulaExpression

}



CROSS JOIN using LINQ

from meta in Metadatas
from type in  MetadataTypes
where meta.DatabaseID == 1 && meta.MetadataTypeID==1
select new
{
       meta.MetadataID,
       meta.MetadataTypeID,
       meta.DatabaseID,
       type.CreatedBy,
       type.MetadataTypeName
}












































No comments :

Post a Comment