public void Create(Supplier supplier) { var sqlSupplier = SqlSupplier.FromSupplier(supplier); context.Suppliers.Add(sqlSupplier); context.SaveChanges(); }
public void Update(Supplier supplier) { var sqlSupplier = SqlSupplier.FromSupplier(supplier); context.SetModified(sqlSupplier); context.SaveChanges(); }
/// <summary>Converts a domain model object to a form that is suitable for storing in a relational database.</summary> public static SqlSupplierGroup FromSupplierGroup(SupplierGroup group) { if (group == null) { throw new ArgumentNullException("Supplier group can't be null."); } return(new SqlSupplierGroup { Id = group.Id, Name = group.Name, Suppliers = group.Suppliers.Select(s => SqlSupplier.FromSupplier(s)).ToList() }); }