what kind of data FirstOrDefault or SingleOrDefault will return.
suppose my query return 3 record like
empid ename salary
----- ----- ------
1 joy 1500
2 rob 4500
3 jen 6500
so if we use FirstOrDefault or SingleOrDefault then what kind of resultset i will get. please explain with example. thanks
SingleOrDefault will return exception because it wait to get one record or no record and FirstOrDefault will return the first record (1 joy 1500)
you can use SingleOrDefault when your where contains a condition that will surly return on record in you case –
where empid == 1obviously you want only one DB record with the ID 1