[]
LINQ queries demonstrate how to operate and query the Snowflake objects wrapped in an Entity Framework data model. Listed below are some examples of LINQ queries supported by the Entity framework. In the following example, it is used CallCenter.cs file to map the CallCenter Datatable.
Select and Filter
Retrieve records from the CALL_CENTER table where the CC_CALL_CENTER_SK is "1.
var records = from p in context.CallCenters
where p.CcCallCenterSk == 1
select new { p.CcCallCenterSk, p.CcName, p.CcClass };
Contains
Retrieve records from the CALL_CENTER table where the cc_class property contains the substring "large".
var records = context.CallCenters.Where(x => x.CcClass.Contains("large"));
Limit
Retrieve the first 10 records from the CALL_CENTER table.
var records = (from p in context.CallCenters
select p).Take(10); //taking 10 records
Order by
Retrieve all records from the CALL_CENTER table and sort them in descending order based on the cc_class property.
var records = (from p in context.CallCenters
orderby p.CcCallCenterSk descending//Implementing Order By
select p);
Count
Count all entities that match a given criterion.
Query based on the number of records selected
Group By
Group records from the CALL_CENTER table based on the cc_class property. The groups are then ordered in descending order based on the cc_class.
var sampleTable = context.CallCenters.AsEnumerable();
var queryCreatedBy = from b in sampleTable
group b by b.CcClass into newGroup //Linq Group Query based on CcClass
orderby newGroup.Key descending
select newGroup;