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

ToParams – string extension

Posted by: RcBuilder  /   Category: Dictionary / Extensions / Linq / List / Reference Types / SOURCE CODE   /   1 Comment
28
May
2014

ToParams - string extension ResponseParams public class ResponseParams { private Dictionary<string, string> _prms = null; public ResponseParams() { _prms = new Dictionary<string, string>(); } public ResponseParams(IEnumerable<KeyValuePair<string, string>> prms) : this() { foreach (var p in prms) _prms = p.Value; } public string this { get { return _prms; } set { if (!_prms.ContainsKey(Name)) // new _prms.Add(Name, value); else // update _prms = value; } } } Extensions internal static class Extensions { public static ResponseParams ToParams(this string me){ var res = from.

Read more

HttpRuntime Cache with dictionary

Posted by: RcBuilder  /   Category: Cache / Dictionary / Linq / SOURCE CODE   /   2 Comments
04
May
2014

HttpRuntime.Cache with dictionary public Group GetGroupCache(string groupName) { Dictionary<string, Group> groups = null; string CACHE_KEY = "MT4_GROUPS"; if (HttpRuntime.Cache == null) { var temp = GetGroups(); if (temp.Count > 0) { groups = temp.ToDictionary(x => x.Name, x => x); HttpRuntime.Cache.Add(CACHE_KEY, groups, null, DateTime.Now.AddHours(3), TimeSpan.Zero, CacheItemPriority.High, null); } } else groups = (Dictionary<string, Group>)HttpRuntime.Cache; return groups; } // need to implement  Group.

Read more

Converter – Report Item 2 Csv Row

Posted by: RcBuilder  /   Category: Converters / Linq / List / SOURCE CODE   /   No Comments
04
May
2014

public class ReportItem { public Guid AccountId { set; get; } public string Email { set; get; } public string AccountStatus { set; get; } public string MainTP { set; get; } public string FirstName { set; get; } public string LastName { set; get; } public string OptIn { set; get; } public DateTime LastUpdate { set; get; } } public class Converters { public static.

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