Пример #1
0
        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");
                }
            }
        }
Пример #2
0
        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");
                }
            }
        }
Пример #3
0
 partial void DeleteMessage(Message instance);
Пример #4
0
 partial void UpdateMessage(Message instance);
Пример #5
0
 partial void InsertMessage(Message instance);
Пример #6
0
		private void detach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Thread = null;
		}
Пример #7
0
		private void attach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Thread = this;
		}