private static void UtcTime() { Console.WriteLine("--------------DateTime test--------------"); using (new TransactionScope()) { var date = DateTime.UtcNow; date = new DateTime(date.Ticks - (date.Ticks % TimeSpan.TicksPerSecond)); int id; using (var context = EfContextFactory.CreateContext()) { var owner = context.Accounts.First(); var thread = context.Threads.First(); var message = new Message { Date = date, Owner = owner, Sender = owner, Receiver = owner, Thread = thread }; context.Messages.Add(message); context.SaveChanges(); id = message.Id; } using (var context = EfContextFactory.CreateContext()) { var fromDatabase = context.Messages.Find(id); CompareDates(date, fromDatabase.Date, "Ef"); } } using (new TransactionScope()) { var date = DateTime.UtcNow; date = new DateTime(date.Ticks - (date.Ticks % TimeSpan.TicksPerSecond)); int id; using (var context = Linq2SqlContextFactory.CreateContext()) { var owner = context.Accounts.First(); var thread = context.Threads.First(); var message = new Linq2Sql.Message { Date = date, Owner = owner, Sender = owner, Reciever = owner, Thread = thread }; context.Messages.InsertOnSubmit(message); context.SubmitChanges(); id = message.Id; } using (var context = Linq2SqlContextFactory.CreateContext()) { var fromDatabase = context.Messages.First(f => f.Id == id); CompareDates(date, fromDatabase.Date, "Linq2Sql"); } } }
private static void UtcTime() { Console.WriteLine("--------------DateTime test--------------"); using (new TransactionScope()) { var date = DateTime.UtcNow; date = new DateTime(date.Ticks - (date.Ticks%TimeSpan.TicksPerSecond)); int id; using (var context = EfContextFactory.CreateContext()) { var owner = context.Accounts.First(); var thread = context.Threads.First(); var message = new Message {Date = date, Owner = owner, Sender = owner, Receiver = owner, Thread = thread}; context.Messages.Add(message); context.SaveChanges(); id = message.Id; } using (var context = EfContextFactory.CreateContext()) { var fromDatabase = context.Messages.Find(id); CompareDates(date, fromDatabase.Date, "Ef"); } } using (new TransactionScope()) { var date = DateTime.UtcNow; date = new DateTime(date.Ticks - (date.Ticks%TimeSpan.TicksPerSecond)); int id; using (var context = Linq2SqlContextFactory.CreateContext()) { var owner = context.Accounts.First(); var thread = context.Threads.First(); var message = new Linq2Sql.Message {Date = date, Owner = owner, Sender = owner, Reciever = owner, Thread = thread}; context.Messages.InsertOnSubmit(message); context.SubmitChanges(); id = message.Id; } using (var context = Linq2SqlContextFactory.CreateContext()) { var fromDatabase = context.Messages.First(f => f.Id == id); CompareDates(date, fromDatabase.Date, "Linq2Sql"); } } }
partial void DeleteMessage(Message instance);
partial void UpdateMessage(Message instance);
partial void InsertMessage(Message instance);
private void detach_Messages(Message entity) { this.SendPropertyChanging(); entity.Thread = null; }
private void attach_Messages(Message entity) { this.SendPropertyChanging(); entity.Thread = this; }