RcBuilder@walla.com
call centre: 054-5614020

LINQ – Find vs Single vs First

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

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.

Read more

Convert To Dictionary

Posted by: RcBuilder  /   Category: Dictionary / Generic T / Lambda / Linq / List / SOURCE CODE   /   No Comments
05
Oct
2014

Convert To Dictionary using System; using System.Collections.Generic; using System.Linq; class ConvertToDictionary { private List<string> values = new List<string>() { "ROBY", "AVI", "ISSAC", "YOSSI", "IDAN", "SHARON" }; public void ConvertAnonymous() { var res = from item in values select new { MyName = item, item.Length }; Dictionary<string, int> dic = res.ToDictionary(k => k.MyName, k => k.Length); foreach (var keypair in dic) Console.WriteLine(keypair.Key + " = " + keypair.Value); } public.

Read more

Predicate query

Posted by: RcBuilder  /   Category: IEnumerable / Interfaces / Lambda / Linq / Predicate / SOURCE CODE   /   No Comments
23
Sep
2014

Predicate query user entity public class User{ public int Id{set;get;} public string Name{set;get;} public byte Age{set;get;} public static List<User> users = new List<User>() { {new User(){ Name = "ROBY", Age= 30, Id = 1}}, {new User(){ Name = "ISAAC", Age= 20, Id = 2}}, {new User(){ Name = "AVI", Age= 17, Id = 3}}, {new User(){ Name = "RON", Age= 40, Id = 4}}, {new User(){.

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