private static void Post_ProductFamily_link_Products() { Container ctx = new Container(); Console.WriteLine("\t<< post productfamily..products >>"); var product = ctx.Products.OrderBy(p => p.ID).First(); // OrderBy need to avoid Take throw. var family = ctx.ProductFamilies.OrderBy(pf => pf.ID).First(); ctx.AddLink(family, "Products", product); ctx.SaveChanges(); }
private static void Post_ProductFamily_link_Products() { var container = new Container(); Console.WriteLine("\n\t<< post productfamily..products >>"); var product = container.Products.OrderBy(p => p.Id).First(); // OrderBy need to avoid Take throw. var family = container.ProductFamilies.OrderBy(pf => pf.Id).First(); Console.WriteLine("\tAssociating \n\tProduct: Id={0}, Name={1} \n\tTo\n\tProudctFamily: Id={2}, Name={3}", product.Id, product.Name, family.Id, family.Name); container.AddLink(family, "Products", product); container.SaveChanges(); }