Just add defaultValue parameter in CreateTable method for property: public partial class TestSimpleEntity : DbMigration { public override void Up() { CreateTable( “dbo.SimpleEntities”, c => new { id = c.Long(nullable: false, identity: true), name = c.String(), deleted = c.Boolean(nullable: false, defaultValue: true), }) .PrimaryKey(t => t.id); } public override void Down() { DropTable(“dbo.SimpleEntities”); } } After that, run update-database -verbose command, […]
Tag: integer
IndexOf() and LastIndexOf() in C#
The IndexOf() method returns the index number of the first matched character whereas the LastIndexOf() method returns the index number of the last matched character. using System; public class StringExample { public static void Main(string[] args) { string s1 = “Hello C#”; int first = s1.IndexOf(‘l’); int last = s1.LastIndexOf(‘l’); Console.WriteLine(first); Console.WriteLine(last); } } Output: […]
How to split numeric and decimal parts in ReportViewer
‘Int’ Function returns the integer protion of a number. For integer part: =Int(3.14159) -> This gives the number 3 or you can use with that value comes from DataSource =Int(Fields!TheDataSourceField.Value) For decimal part: =3.14159 – Int(3.14159) -> This gives a value close to 0.14159 or you can use with that value comes from DataSource =Fields!TheDataSourceField.Value […]
Convert comma separated string into a List in C#
string myList = “9,3,12,43,2”; List<int> intList = myList.Split(‘,’).Select(int.Parse).ToList();
Converting a List to a comma separated string in C#
List<int> list = new List<int>() {1,2,3}; string.Join<int>(“,”, list) Join has generic overloads. It is so much easier to use it in that way to convert your list to the different types.