This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Provides projection mapping from an IQueryable sourceto a target type. | |
| /// | |
| /// This allows from strongly-typed mapping and querying only necessary fields from the database. | |
| /// It takes the place of Domain -> ViewModel mapping as it allows the ViewModel to stay as | |
| /// IQueryable. AutoMapper works on in-memory objects and will pull all full records to perform | |
| /// a collection mapping. Use AutoMapper for Input -> Domain scenarios, but not DAL. | |
| /// | |
| /// Reference: http://devtrends.co.uk/blog/stop-using-automapper-in-your-data-access-code | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| dynamic dyn = 1; | |
| object obj = 1; | |
| dyn = dyn + 3; // No Compilation Error | |
| //obj = obj + 3; //Compilation error (Operator '+' cannot be applied to operands of type 'object' and 'int') | |
| System.Console.WriteLine(dyn.GetType());//typeof (Int32) | |
| System.Console.WriteLine(obj.GetType());//typeof (Int32) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| //this sample Works great in Linqpad | |
| Console.WriteLine("Custom Decimal format in en-US region settings "); | |
| var culture = new System.Globalization.CultureInfo("en-US"); | |
| Console.WriteLine(string.Format(culture,"\t{0:#,0.00} : {1:#,0.00}", 1234256.55583, 123344256.555)); | |
| Console.WriteLine(string.Format(culture,"\t{0:#,0.00}", 7200)); | |
| Console.WriteLine(string.Format(culture,"\t{0:#,0.00}", 0.005)); | |
| Console.WriteLine(string.Format(culture,"\t{0:#,0.00}", -0.006)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| DataTable table1 = new DataTable("Items"); | |
| // Add two columns to the table: | |
| DataColumn column = new DataColumn("id", typeof(System.Int32)); | |
| table1.Columns.Add(column); | |
| column = new DataColumn("item", typeof(System.String)); | |
| table1.Columns.Add(column); |