entity framework select c# code example

Example 1: entities query in

int[] ids = { 1, 2, 3, 4, 5};

var query = from item in db.myTable
            where ids.Contains(item.ID)
            select item;

Example 2: entity framework with query c#

using (var ctx = new SchoolDBEntities())
{
    var studentName = ctx.Students.SqlQuery("Select studentid, studentname, standardId from Student where studentname='Bill'").FirstOrDefault<Student>();
} 
//Reference Link
//https://www.entityframeworktutorial.net/Querying-with-EDM.aspx