Back to list
Views:   3.7K
Replies:  0
Archived

DataObject, Insert Product with Category Example Request

Hi all,
        Can you show me, how to implement insert an Entity with Lookup Attribute(s) in a Insert method, for example, Product Entity that has a Category lookup and there is not any insert sample.

         public Product InsertProduct(Product product)
        {
            using (var context = DataContextFactory.CreateContext())
            {
                context.ProductEntities.InsertOnSubmit(entity);
                context.SubmitChanges();

                // update business object with new version and id
                product.ProductId = entity.ProductId;
                product.Version = VersionConverter.ToString(entity.Version);
            }
        }

 
public class Product : BusinessObject
{
        public Product()  { Version = _versionDefault; }
        public int ProductId { get; set; }
        public string ProductName { get; set; }
        public string Weight { get; set; }
        public double UnitPrice { get; set; }
        public int UnitsInStock { get; set; }
        public Category Category { get; set; }
        public string Version { get; set; }
}

 
Mehmet Sirin Celik, Sep 15, 2012


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0