protected override object ReadRow(IRowReader reader) { LightboxBrand lightboxBrand = LightboxBrand.New(); // Table Fields lightboxBrand.LightboxBrandId = reader.GetInt32("LightboxBrandId"); lightboxBrand.LightboxId = reader.GetInt32("LightboxId"); lightboxBrand.BrandId = reader.GetInt32("BrandId"); lightboxBrand.IsDirty = false; lightboxBrand.ChangedProperties.Clear(); return(lightboxBrand); }
public static Lightbox Update(Lightbox lightbox) { Lightbox lb = LightboxMapper.Instance.Update(lightbox); LightboxBrandMapper.Instance.DeleteLightboxBrands(lb.LightboxId); foreach (Brand brand in lb.Brands) { LightboxBrand o = LightboxBrand.New(); o.LightboxId = lb.LightboxId.GetValueOrDefault(); o.BrandId = brand.BrandId.GetValueOrDefault(); LightboxBrand.Update(o); } return(lb); }
public virtual LightboxBrand Update(LightboxBrand lightboxBrand) { if (!lightboxBrand.IsDirty || lightboxBrand.IsNull) { // Nothing to do - no point hammering the database unnecessarily return(lightboxBrand); } IDbCommand command = CreateCommand(); if (lightboxBrand.IsNew) { // Adding command.CommandText = "INSERT INTO [LightboxBrand] ([LightboxId], [BrandId]) VALUES (@lightboxId, @brandId) ; SELECT @@identity AS NewId;"; } else { // Updating command.CommandText = "UPDATE [LightboxBrand] SET [LightboxId] = @lightboxId, [BrandId] = @brandId WHERE LightboxBrandId = @lightboxBrandId"; } command.Parameters.Add(CreateParameter("@lightboxId", lightboxBrand.LightboxId)); command.Parameters.Add(CreateParameter("@brandId", lightboxBrand.BrandId)); if (lightboxBrand.IsNew) { lightboxBrand.LightboxBrandId = Convert.ToInt32(ExecScalar(command)); } else { command.Parameters.Add(CreateParameter("@lightboxBrandId", lightboxBrand.LightboxBrandId)); ExecuteCommand(command); } lightboxBrand.IsDirty = false; lightboxBrand.ChangedProperties.Clear(); return(lightboxBrand); }
public static LightboxBrand FindOne(LightboxBrandFinder finder) { LightboxBrand LightboxBrand = LightboxBrandMapper.Instance.FindOne(finder); return(LightboxBrand ?? Empty); }
public static LightboxBrand Update(LightboxBrand lightboxBrand) { return(LightboxBrandMapper.Instance.Update(lightboxBrand)); }
public static LightboxBrand Get(Nullable <Int32> LightboxBrandId) { LightboxBrand LightboxBrand = LightboxBrandMapper.Instance.Get(LightboxBrandId); return(LightboxBrand ?? Empty); }