RcBuilder@walla.com
call centre: 054-5614020

LINQ – Find vs Single vs First

12
Oct
2014
Posted by: RcBuilder  /   Category: Dictionary / Lambda / Linq / List / Predicate   /   No Comments

LINQ – Find vs Single vs First

Find()
get an item by primary key.
return null if not exists.
look in the context before going to the database (EF).

Single()
get an single item by an expression.
throw an exception if not exists or there’s more than one.

SingleOrDefault()
get an single item by an expression.
return null if not exists.
throw an exception if there’s more than a one.

First()
get the first item by an expression.
throw an exception if not exists.

FirstOrDefault()
get the first item by an expression.
return null if not exists.

Author Avatar

About the Author

בניית אתרים ופתרונות טכנולוגים | RcBuilder

No Comments


  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים