public Customer UpdateWithSpec(int id) { IDataQuerySpecification <Customer> qrySpec = new CustomerDataQuerySpecification(cust => cust.Id == id && !cust.IsInactive); qrySpec.Includes.Add(cust => cust.DeliveryProducts); var c = qry.Find(qrySpec); c.Description = $"Customer test {c.Name} - {DateTime.Now}"; c.CommencementDate = DateTime.Today.AddMonths(-3); if (c.DeliveryProducts.Count > 0) { c.DeliveryProducts[0].Price = 11.50M; c.DeliveryProducts[0].SetDirty(); } var dp = new DeliveryProduct() { Name = $"DP {new Random().Next(1, 99)}", HasDate = true, Price = 20M, SortOrder = 20, IsNew = true }; c.DeliveryProducts.Add(dp); cmd.Update(c, cmdSpec); return(c); }