-->

Jul 2, 2014

First vs FirstOrDefault in LINQ

First vs FirstOrDefault in LINQ
S.NoFirstFirstOrDefault
1Gives first record from the collection, if collection doesn't have any object then throws error.FirstOrDefault extension method is used to retrieve the first element from the collection, if not then gives null

Jul 1, 2014

LINQ To SQL and LINQ To Object

LINQ To SQL and LINQ To Object
S.NoLINQ To SQLLINQ To Object
1needs a Data Context object.doesn’t need any intermediate LINQ provider or API.
2returns data of type IQueryable.returns data of type IEnumerable.
3translated to SQL by way of Expression Trees, which allow them to be evaluated as a single unit and translated to the appropriate and optimal SQL statementsdoes not need to be translated.
4translated to SQL calls and executed on the specified database.executed in the local machine memory.