public int Add(BWS.DB.DAL.ProductMaster product, string strColorSizeIds) { try {
ProductDataDataContext objDataContext = new ProductDataDataContext(); if (strColorSizeIds.Length > 0) { string[] strArrayColorSize = strColorSizeIds.Split('_'); for (int i = 0; i < strArrayColorSize.Length; i++) { product.ChildProducts.Add(new ChildProducts() { BarCode = product.BarCode, CanInventorize = product.CanInventorize, ColorId = Convert.ToInt32(strArrayColorSize[i].Split(',')[1]), SizeId = Convert.ToInt32(strArrayColorSize[i].Split(',')[0]), CompanyId = product.CompanyId, Description = product.Description, haveColorSizeMatrix = false, id = 0, ImageUrl = product.ImageUrl, isSerialNoReq = product.isSerialNoReq, MinInventoryLevel = product.MinInventoryLevel, ParentProdId = product.id, ProductClassId = product.ProductClassId, ProductCode = "0", ProductFamilyId = product.ProductFamilyId, ProductSuppliersCostGrids = product.ProductSuppliersCostGrids , SellingPrice = product.SellingPrice, IsActive = product.IsActive }); } } objDataContext.ProductMasters.InsertOnSubmit(product); objDataContext.SubmitChanges();
return 1; } catch { return -1; } }
ProductSuppliersCostGrids is my class in same datacontext and I set the relationship it to the productmaster class.
My problem is when I used above code( ProductSuppliersCostGrids = product.ProductSuppliersCostGrids) to insert the same suppliers list to childproducts, It's only added to first child product, not even in the main product and other child products..
Why?
|
No responses found. Be the first to respond and make money from revenue sharing program.
|