/// <summary> /// Run the application. /// </summary> public override BoolMessageItem Execute() { Console.WriteLine("===================================================="); Console.WriteLine("Entity "); // Example 1 : Using Entity base class. IEntity entity = new Person() { Name = "kishore" }; Console.WriteLine("Id, Persistant and Audit fields."); Console.WriteLine("These fields are set by EntityService if using CommonLibrary Entity-Model Services."); Console.WriteLine("Id ", entity.Id); Console.WriteLine("IsPersistant ", entity.IsPersistant()); Console.WriteLine("CreateDate ", entity.CreateDate); Console.WriteLine("CreateUser ", entity.CreateUser); Console.WriteLine("UpdateDate ", entity.UpdateDate); Console.WriteLine("UpdateUser ", entity.UpdateUser); Console.WriteLine("UpdateComment ", entity.UpdateComment); // Example 2 : Using Entity<T> generic base class to get the parameterless CRUD methods. // 1st initialize the repositories. EntityRegistration.Register <Person2>(new RepositoryInMemory <Person2>("Id"), false); var p2 = new Person2() { Name = "kishore" }; p2.Create(); p2.Name = "updated"; p2.Update(); p2.GetAll(); p2.Save(); p2.Delete(); // Example 3 : Implement IEntityVersionable to get versioning on the entities. // Wrap the real repository w/ the RepositoryVersionable decorator to get versioning behaviour. EntityRegistration.Register <Person3>(new RepositoryVersioned <Person3>(new RepositoryInMemory <Person3>("Id,Version,VersionRefId")), false); var p3 = new Person3(); p3.Create(); p3.Name = "updated"; p3.Update(); p3.GetAll(); var p4 = new Person4(); p4.Name = "kishore"; p4.Phone = "111-111-1111"; p4.RegisterDate = DateTime.Today; p4.About = "artist"; p4.Age = 30; p4.Email = "*****@*****.**"; bool isValid = p4.IsValid; return(BoolMessageItem.True); }