public virtual bool Update(Haulier obj) { //var getObj = GetById(obj.Id); //_db.Entry(getObj).State = System.Data.Entity.EntityState.Detached; _db.Entry(obj).State = EntityState.Modified; //_db.Hauliers.Attach(obj); _db.SaveChanges(); return(true); }
public SimpleMembershipInitializer() { Database.SetInitializer <UsersContext>(null); try { using (var context = new UsersContext()) { if (!context.Database.Exists()) { // Create the SimpleMembership database without Entity Framework migration schema ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } WebSecurity.InitializeDatabaseConnection("SecurityDb", "UserProfile", "UserId", "UserName", autoCreateTables: true); } catch (Exception ex) { throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex); } using (var context = new LiteDispatchDbContext(new ModelCreator())) { if (context.Database.Exists()) { return; } context.Database.CreateIfNotExists(); using (var transManager = Container.GlobalContext.TransFactory.CreateManager()) { transManager.ExecuteCommand(locator => { var haulier = locator.FindAll <Haulier>().SingleOrDefault(h => h.Name == "BlueWhale"); if (haulier != null) { return(Mapper.Map <Haulier, HaulierModel>(haulier)); } haulier = Haulier.Create(locator, new HaulierModel { Name = "BlueWhale" }); return(Mapper.Map <Haulier, HaulierModel>(haulier)); }); } } }
public void Install() { EntityToModel.Install(); ModelToEntity.Install(); var factory = new TransManagerFactoryEF(ModelCreator); using (var transManager = factory.CreateManager()) { transManager.ExecuteCommand(locator => { var haulier = locator.FindAll <Haulier>().SingleOrDefault(h => h.Name == "BlueWhale"); if (haulier != null) { return(Mapper.Map <Haulier, HaulierModel>(haulier)); } haulier = Haulier.Create(locator, new HaulierModel { Name = "BlueWhale" }); return(Mapper.Map <Haulier, HaulierModel>(haulier)); }); } }
public void Detach(Haulier obj) { _db.Entry(obj).State = EntityState.Detached; }
//public virtual IEnumerable<Haulier> GetList(int take) //{ // return _db.Hauliers.Take(take).ToList(); //} public virtual long Add(Haulier obj) { _db.Hauliers.Add(obj); _db.SaveChanges(); return(obj.Id); }
public bool Update(Haulier obj) { return(_haulierRepository.Update(obj)); }
//public IEnumerable<Haulier> GetList(int take) //{ // return _haulierRepository.GetList(100); //} public long Add(Haulier obj) { return(_haulierRepository.Add(obj)); }