Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Regarding a EF linq query

$
0
0

see the below code

using (var context = new SchoolDBEntities())
{var stud1 = (from s in context.Students.Include("Standard")
                where s.StudentName == "Student1"
                select s).FirstOrDefault<Student>();
}

tell me why we need to specify studen inside firstordefault like FirstOrDefault<Student>() ?

if i write like this way then it will not work ?

using (var context = new SchoolDBEntities())
{
    var stud1 = (from s in context.Students.Include("Standard")
                where s.StudentName == "Student1"
                select s).FirstOrDefault();
}


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>