private tblIncoming CreateIncoming(tblLot oldLot, Inventory inventory) { var packaging = OldContextHelper.GetPackaging(inventory.PackagingProduct); var treatment = OldContextHelper.GetTreatment(inventory); var transType = TransType.Other; switch (inventory.LotTypeEnum.ToProductType()) { case ProductTypeEnum.Additive: transType = TransType.Ingredients; break; case ProductTypeEnum.Packaging: transType = TransType.Packaging; break; } return(new tblIncoming { EmployeeID = oldLot.EmployeeID, EntryDate = oldLot.EntryDate.Value, TTypeID = (int?)transType, Lot = oldLot.Lot, Quantity = inventory.Quantity, PkgID = packaging.PkgID, LocID = inventory.Location.LocID.Value, TrtmtID = treatment.TrtmtID, Tote = inventory.ToteKey, Company_IA = oldLot.Company_IA, NetWgt = packaging.NetWgt, TtlWgt = inventory.Quantity * packaging.NetWgt, }); }
public static void SetLotBatchAttributes(tblLot lot, List<LotAttribute> lotAttributes) { var asta = lotAttributes.FirstOrDefault(a => a.AttributeShortName == Constants.ChileAttributeKeys.Asta); if(asta != null) { lot.bAsta = (decimal?)asta.AttributeValue; } var h2o = lotAttributes.FirstOrDefault(a => a.AttributeShortName == Constants.ChileAttributeKeys.H2O); if(h2o != null) { lot.bH2O = (decimal?)h2o.AttributeValue; } var scan = lotAttributes.FirstOrDefault(a => a.AttributeShortName == Constants.ChileAttributeKeys.Scan); if(scan != null) { lot.bScan = (decimal?)scan.AttributeValue; } var ab = lotAttributes.FirstOrDefault(a => a.AttributeShortName == Constants.ChileAttributeKeys.AB); if(ab != null) { lot.bAB = (decimal?)ab.AttributeValue; } var gran = lotAttributes.FirstOrDefault(a => a.AttributeShortName == Constants.ChileAttributeKeys.Gran); if(gran != null) { lot.bGran = (decimal?)gran.AttributeValue; } }
private void SetOutgoingRecords(tblLot tblLot, ChileLotProduction production) { foreach (var previousInput in OldContext.tblOutgoings.Where(o => o.NewLot == tblLot.Lot).ToList()) { OldContext.tblOutgoings.DeleteObject(previousInput); } foreach (var item in production.PickedInventory.Items) { var sourceLotNumber = LotNumberBuilder.BuildLotNumber(item); var packaging = OldContextHelper.GetPackaging(item.PackagingProduct); OldContext.tblOutgoings.AddObject(new tblOutgoing { EmployeeID = tblLot.EmployeeID, EntryDate = DateTime.UtcNow.ConvertUTCToLocal().RoundMillisecondsForSQL(), Lot = sourceLotNumber, NewLot = tblLot.Lot, TTypeID = (int?)TransType.DeHy, PkgID = packaging.PkgID, Tote = item.ToteKey, Quantity = item.Quantity, NetWgt = packaging.NetWgt, TtlWgt = item.Quantity * packaging.NetWgt, LocID = item.FromLocation.LocID.Value, TrtmtID = 0 }); } }
public void Clears_missing_attribute_values() { //Arrange var lot = new tblLot { Ash = 11, AToxin = 22, Gluten = 33 }; var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.IsNotNull(lot.AvgAsta); Assert.IsNotNull(lot.AvgScov); Assert.IsNotNull(lot.Scan); Assert.IsNull(lot.Ash); Assert.IsNull(lot.AToxin); Assert.IsNull(lot.Gluten); }
public void SetIncomingItems(ProductionBatch productionBatch, tblLot lot) { var currentIncoming = lot.tblIncomings.Where(i => i.TTypeID == (int?)TransType.Production).ToList(); var newIncoming = productionBatch.Production.Results.ResultItems.Select(CreateIncoming).ToList(); //EF has issue with tracking entities with duplicate or no primary keys and considering them equal. Answer seems to be to disable entity tracking on the object set. //http://stackoverflow.com/questions/4994203/unbelievable-duplicate-in-an-entity-framework-query // -RI 2016/2/1 var mergeOption = OldContext.ViewAvailables.MergeOption; OldContext.ViewAvailables.MergeOption = MergeOption.NoTracking; var inventory = OldContext.ViewAvailables.Where(i => i.Lot == lot.Lot).ToList(); OldContext.ViewAvailables.MergeOption = mergeOption; foreach (var modification in GetModifications(currentIncoming, newIncoming)) { var item = inventory.SingleOrDefault(i => i.LocID == modification.LocID && i.PkgID == modification.PkgID && i.TrtmtID == modification.TrtmtID); if ((item != null ? item.Quantity : 0) + modification.ModifyQuantity < 0) { throw new Exception(string.Format("Inventory Lot[{0}] PkgID[{1}] LocID[{2}] TrtmtID[{3}] would have resulted in negative quantity.", modification.Lot, modification.PkgID, modification.LocID, modification.TrtmtID)); } } currentIncoming.ForEach(i => OldContext.tblIncomings.DeleteObject(i)); newIncoming.ForEach(i => OldContext.tblIncomings.AddObject(i)); }
private void SetIncomingRecords(tblLot tblLot, IEnumerable <LotProductionResultItem> resultItems) { foreach (var item in tblLot.tblIncomings.ToList()) { OldContext.tblIncomings.DeleteObject(item); } foreach (var item in resultItems) { var packaging = OldContextHelper.GetPackaging(item.PackagingProduct); tblLot.tblIncomings.Add(new tblIncoming { EmployeeID = tblLot.EmployeeID, EntryDate = tblLot.EntryDate.Value, Lot = tblLot.Lot, TTypeID = (int?)TransType.MnW, PkgID = packaging.PkgID, Quantity = item.Quantity, NetWgt = packaging.NetWgt, TtlWgt = item.Quantity * packaging.NetWgt, LocID = item.Location.LocID.Value, TrtmtID = 0 }); } }
public void Returns_false_and_LotStat_will_not_have_been_set_if_no_LotAttributes_or_defects_exist() { var oldLot = new tblLot(); Assert.IsFalse(LotSyncHelper.SetProductSpecDefectStat(oldLot, null, null, null)); Assert.IsNull(oldLot.LotStat); }
private static void UpdateOldLot(tblLot oldLot, Lot newLot, Customer customer, bool completedOverride, bool updateSerializationOnly) { if (!updateSerializationOnly) { if (customer != null) { oldLot.Company_IA = customer.Company.Name; } oldLot.Notes = newLot.Notes; oldLot.PurchOrder = newLot.PurchaseOrderNumber; oldLot.ShipperNum = newLot.ShipperNumber; if (string.IsNullOrWhiteSpace(oldLot.Company_IA) || newLot.Vendor != null) { oldLot.Company_IA = newLot.Vendor == null ? null : newLot.Vendor.Name; } LotSyncHelper.SetLotAttributes(oldLot, newLot.Attributes.ToList()); LotSyncHelper.SetTestData(oldLot, newLot); LotSyncHelper.SetLotStat(oldLot, newLot, completedOverride, newLot.ChileLot == null ? null : newLot.ChileLot.ChileProduct.ProductAttributeRanges.ToList()); } oldLot.Serialized = SerializableLot.Serialize(newLot); }
private static tblLotAttributeHistory CreateNewLotHistoryRecord(tblLot lot) { var history = new tblLotAttributeHistory { Lot = lot.Lot, ArchiveDate = DateTime.UtcNow.ConvertUTCToLocal().RoundMillisecondsForSQL(), EmployeeID = lot.EmployeeID, EntryDate = lot.EntryDate, Notes = lot.Notes, TestDate = lot.TestDate, TesterID = lot.TesterID, TestNotes = lot.TestNotes, LotStat = lot.LotStat, LoBac = lot.LoBac }; foreach (var attribute in StaticAttributeNames.AttributeNames) { var get = lot.AttributeGet(attribute); var set = history.AttributeSet(attribute); if (get != null && set != null) { set(get()); } } return(history); }
public static bool SetProductSpecDefectStat(tblLot oldLot, IEnumerable <LotAttribute> lotAttributes, IEnumerable <IAttributeRange> productSpec, IEnumerable <IAttributeDefect> lotAttributeDefects) { var specDefects = GetProductSpecDefects(lotAttributes, productSpec, lotAttributeDefects); var defectLotStat = GetLotStatHelper.GetProductSpecDefectStat(specDefects); if (defectLotStat != null) { oldLot.LotStat = (int?)defectLotStat.LotStat; if (defectLotStat.LotStat == LotStat.See_Desc && !string.IsNullOrWhiteSpace(defectLotStat.Description)) { if (string.IsNullOrWhiteSpace(oldLot.Notes)) { oldLot.Notes = defectLotStat.Description; } else if (!oldLot.Notes.ToUpper().Contains(defectLotStat.Description.ToUpper())) { oldLot.Notes = string.Format("{0} / {1}", oldLot.Notes, defectLotStat.LotStat); } } return(true); } return(false); }
public void Returns_false_and_no_LotStat_will_have_been_set_it_no_unresolved_InHouseContamination_defects_exist() { //Arrange var lotWithNoDefects = new Lot { LotDefects = new LotDefect[0] }; var lotWithResolvedDefects = new Lot { LotDefects = new[] { BuildLotDefect(DefectTypeEnum.InHouseContamination, true), BuildLotDefect(DefectTypeEnum.InHouseContamination, true) } }; var oldLot = new tblLot { LotStat = null }; //Act-Assert Assert.IsFalse(LotSyncHelper.SetInHouseContamination(oldLot, lotWithNoDefects)); Assert.IsNull(oldLot.LotStat); Assert.IsFalse(LotSyncHelper.SetInHouseContamination(oldLot, lotWithResolvedDefects)); Assert.IsNull(oldLot.LotStat); }
public void SetOutgoingItems(ProductionBatch productionBatch, tblLot lot) { var currentOutgoing = lot.tblOutgoingInputs.Where(i => i.TTypeID == (int?)TransType.Production).ToList(); var newOutgoing = lot.inputBatchItems.Select(b => CreateOutgoingFromBatchItem(b, productionBatch)).ToList(); currentOutgoing.ForEach(o => OldContext.tblOutgoings.DeleteObject(o)); newOutgoing.ForEach(o => OldContext.tblOutgoings.AddObject(o)); }
private static void UpdateLot(tblLot lot, ProductionBatch productionBatch) { lot.TargetWgt = (decimal?)productionBatch.TargetParameters.BatchTargetWeight; lot.TgtAsta = (decimal?)productionBatch.TargetParameters.BatchTargetAsta; lot.TgtScan = (decimal?)productionBatch.TargetParameters.BatchTargetScan; lot.TgtScov = (decimal?)productionBatch.TargetParameters.BatchTargetScoville; lot.Notes = productionBatch.Production.ResultingChileLot.Lot.Notes; }
public static void SetTestData(tblLot oldLot, Lot newLot) { var actualAttributes = newLot.Attributes.Where(a => !a.Computed).ToList(); var testDate = actualAttributes.Select(a => (DateTime?)a.AttributeDate).DefaultIfEmpty(null).Max(); var testerId = actualAttributes.OrderByDescending(a => a.AttributeDate).Select(a => (int?)a.EmployeeId).FirstOrDefault(); oldLot.TestDate = testDate == DateTime.MinValue ? null : testDate; oldLot.TesterID = testerId; }
public void Returns_true_and_LotStat_will_have_been_set_as_expected_for_ProductSpec_defect() { var oldLot = new tblLot(); Assert.IsTrue(LotSyncHelper.SetProductSpecDefectStat(oldLot, null, null, new List <IAttributeDefect> { GetLotStatHelperTests.BuildProductSpecDefect(StaticAttributeNames.H2O, 1, 2, 3, false) })); Assert.AreEqual((int)LotStat.Low_Water, oldLot.LotStat); }
public static bool SetLotHoldStatus(tblLot oldLot, Lot newLot) { var lotStat = GetLotStatHelper.GetHoldLotStat(newLot.Hold, newLot.ProductionStatus); if (lotStat != null) { oldLot.LotStat = (int)lotStat.Value; return(true); } return(false); }
public void SetResults(ProductionBatch productionBatch, tblLot lot) { var productionStart = productionBatch.Production.Results.ProductionBegin.ConvertUTCToLocal().RoundMillisecondsForSQL(); lot.Shift = productionBatch.Production.Results.ShiftKey; lot.Produced = productionStart.Date; // this is how they are expecting to find lots for entry of production results. -VK 2/19/14 lot.ProductionDate = productionBatch.LotDateCreated.Date; lot.BatchBegTime = productionStart; lot.BatchEndTime = productionBatch.Production.Results.ProductionEnd.ConvertUTCToLocal().RoundMillisecondsForSQL(); lot.ProductionLine = ProductionLineParser.GetProductionLineNumber(productionBatch.Production.Results.ProductionLineLocation); lot.BatchStatID = (int?)BatchStatID.Produced; SetIncomingItems(productionBatch, lot); SetOutgoingItems(productionBatch, lot); }
private static void ArrangeLots(string description, out tblLot oldLot, out Lot newLot) { newLot = new Lot { LotDefects = new[] { BuildLotDefect(DefectTypeEnum.InHouseContamination, false, description) } }; oldLot = new tblLot { LotStat = null }; }
public void Returns_false_and_LotStat_will_not_have_been_set_if_no_defects_of_ProductSpec_type_exist() { var oldLot = new tblLot(); Assert.IsFalse(LotSyncHelper.SetProductSpecDefectStat(oldLot, null, null, new List <IAttributeDefect> { new LotAttributeDefect { LotDefect = new LotDefect { DefectType = DefectTypeEnum.BacterialContamination }, } })); Assert.IsNull(oldLot.LotStat); }
private void SyncIncomingRecords(ChileMaterialsReceived received, tblLot tblLot, ICollection <tblVariety> varieties) { foreach (var incoming in tblLot.tblIncomings.ToList()) { OldContext.tblIncomings.DeleteObject(incoming); } var treatment = OldContextHelper.GetTreatment(received); var varietyId = varieties.Select(v => v.VarietyID).DefaultIfEmpty(0).Max() + 1; foreach (var item in received.Items) { var packaging = OldContextHelper.GetPackaging(item.PackagingProduct); var variety = varieties.FirstOrDefault(v => v.Variety == item.ChileVariety); if (variety == null) { variety = new tblVariety { VarietyID = varietyId++, Variety = item.ChileVariety, EntryDate = DateTime.Now, InActive = false, SortOrder = varietyId.ToString() }; OldContextHelper.OldContext.tblVarieties.AddObject(variety); varieties.Add(variety); } tblLot.tblIncomings.Add(new tblIncoming { EmployeeID = tblLot.EmployeeID, EntryDate = tblLot.EntryDate.Value, TTypeID = (int?)(received.ChileMaterialsReceivedType == ChileMaterialsReceivedType.Dehydrated ? TransType.DeHy : TransType.Other), Quantity = item.Quantity, TrtmtID = treatment.TrtmtID, Tote = item.ToteKey, VarietyID = variety.VarietyID, Company_IA = tblLot.Company_IA, LocID = item.Location.LocID.Value, DehyLocale = item.GrowerCode, PkgID = packaging.PkgID, NetWgt = packaging.NetWgt, TtlWgt = item.Quantity * packaging.NetWgt }); } }
private tblLot GetOrCreateLot(ChileLotProduction production, out bool newLot) { newLot = false; var lotNumber = LotNumberBuilder.BuildLotNumber(production); var tblLot = OldContext.tblLots .Include(l => l.tblIncomings, l => l.tblOutgoings) .FirstOrDefault(l => l.Lot == lotNumber); if (tblLot == null) { tblLot = new tblLot { Lot = lotNumber, EmployeeID = production.ResultingChileLot.Lot.EmployeeId, EntryDate = production.ResultingChileLot.Lot.TimeStamp.ConvertUTCToLocal().RoundMillisecondsForSQL(), PTypeID = production.LotTypeId, Julian = lotNumber.Julian, BatchNum = production.LotDateSequence, Shift = production.Results.ShiftKey, Notes = "Old Context Synchronization", BatchProdctnOrder = 0, SetTrtmtID = 0, BatchStatID = (int?)BatchStatID.Produced, TargetWgt = 0, //looks like default value set in old context - RI 2014/2/17, tblOutgoings = new EntityCollection <tblOutgoing>(), tblIncomings = new EntityCollection <tblIncoming>() }; OldContext.tblLots.AddObject(tblLot); newLot = true; } var product = OldContextHelper.GetProduct(production.ResultingChileLot.ChileProduct); var productionLine = OldContextHelper.GetProductionLine(production.Results.ProductionLineLocation).Value; var productionDate = production.LotDateCreated.Date; var batchBegTime = production.Results.ProductionBegin.ConvertUTCToLocal().RoundMillisecondsForSQL(); var batchEndTime = production.Results.ProductionEnd.ConvertUTCToLocal().RoundMillisecondsForSQL(); tblLot.ProdID = product.ProdID; tblLot.ProductionLine = productionLine; tblLot.BatchBegTime = batchBegTime; tblLot.BatchEndTime = batchEndTime; tblLot.ProductionDate = productionDate; tblLot.Produced = productionDate; return(tblLot); }
public static bool SetInHouseContamination(tblLot oldLot, Lot newLot) { var inHouseResult = GetLotStatHelper.GetInHouseContaminationLotStat(newLot.LotDefects); if (inHouseResult != null) { oldLot.LotStat = (int?)inHouseResult.LotStat; if (inHouseResult.LotStat == LotStat.See_Desc) { oldLot.Notes = inHouseResult.Description; } return(true); } return(false); }
public static void SetLotAttributes(tblLot oldLot, List <LotAttribute> newAttributes) { var tblLotAttributeHistory = oldLot.tblLotAttributeHistory == null ? null : oldLot.tblLotAttributeHistory.Where(h => h.TestDate == null).OrderBy(h => h.ArchiveDate).FirstOrDefault(); foreach (var oldAttribute in oldLot.GetAttributes(tblLotAttributeHistory)) { var newAttribute = newAttributes.FirstOrDefault(a => oldAttribute.AttributeNameKey.Equals(a)); var newAttributeIsComputed = newAttribute != null && newAttribute.Computed; var newAttributeMustBeActual = oldAttribute.ActualValueRequired || !oldAttribute.Computed; if (newAttributeMustBeActual && newAttributeIsComputed) { continue; } oldAttribute.Value = newAttribute == null ? null : (decimal?)newAttribute.AttributeValue; } }
public void IfAllAttributeTestDatesAreMinDateValue_TestDateIsNull() { // arrange var lot = new tblLot(); var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0, DateTime.MinValue); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f, DateTime.MinValue); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0, DateTime.MinValue); var newLot = new Lot { Attributes = new[] { asta, scoville, scan } }; // act LotSyncHelper.SetTestData(lot, newLot); // assert Assert.AreEqual(null, lot.TestDate); }
public void TesterIdWillBeNullIfNoActualAttributesExist() { // arrange var lot = new tblLot(); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0, new DateTime(2016, 1, 1), true, new EmployeeKeyReturn { EmployeeKey_Id = 123 }); var newLot = new Lot { Attributes = new[] { scan } }; // act LotSyncHelper.SetTestData(lot, newLot); // assert Assert.AreEqual(null, lot.TesterID); }
private tblLot GetOrCreateLot(Lot lot) { var oldLot = _oldContext.GetLot(lot, false); if (oldLot == null) { var lotNumber = LotNumberBuilder.BuildLotNumber(lot); tblProduct product = null; switch (lot.LotTypeEnum.ToProductType()) { case ProductTypeEnum.Additive: var additiveProduct = _unitOfWork.AdditiveProductRepository.FindByKey(lot.AdditiveLot.ToAdditiveProductKey(), p => p.Product); product = _oldContextHelper.GetProduct(additiveProduct.Product.ProductCode); break; case ProductTypeEnum.Chile: var chileProduct = _unitOfWork.ChileProductRepository.FindByKey(lot.ChileLot.ToChileProductKey(), p => p.Product); product = _oldContextHelper.GetProduct(chileProduct.Product.ProductCode); break; case ProductTypeEnum.Packaging: var packagingProduct = _unitOfWork.PackagingProductRepository.FindByKey(lot.PackagingLot.ToPackagingProductKey(), p => p.Product); product = GetOrCreatePackagingProduct(packagingProduct, lot, lot.TimeStamp); break; } oldLot = new tblLot { Lot = lotNumber, EmployeeID = lot.EmployeeId, EntryDate = DateTime.UtcNow.ConvertUTCToLocal().RoundMillisecondsForSQL(), PTypeID = lot.LotTypeId, ProdID = product.ProdID, Julian = lotNumber.Julian, TargetWgt = 0, Notes = "Old Context Synchronization" }; _oldContext.tblLots.AddObject(oldLot); } return(oldLot); }
private static bool CommitLotHistory(tblLot lot, tblLotAttributeHistory history) { if (lot.LotStat != history.LotStat) { return(true); } if (lot.TestDate != history.TestDate) { return(true); } if (lot.TesterID != history.TesterID) { return(true); } foreach (var attribute in StaticAttributeNames.AttributeNames) { var lotGet = lot.AttributeGet(attribute); var historyGet = history.AttributeGet(attribute); if (historyGet != null) { var lotValue = lotGet == null ? null : lotGet(); var historyValue = historyGet(); if (lotValue != null || historyValue != null) { if (lotValue == null || historyValue == null) { return(true); } if (Math.Abs(lotValue.Value - historyValue.Value) > 0.01m) { return(true); } } } } return(false); }
public void Returns_false_and_LotStat_will_not_have_been_set_if_all_defects_for_an_attribute_are_resolved() { var oldLot = new tblLot(); Assert.False(LotSyncHelper.SetProductSpecDefectStat(oldLot, new List <LotAttribute> { new LotAttribute { AttributeShortName = StaticAttributeNames.H2O.ShortName, AttributeValue = 1 }, }, new List <CustomerProductAttributeRange> { new CustomerProductAttributeRange { RangeMin = 2, RangeMax = 3, AttributeShortName = StaticAttributeNames.H2O.ShortName } }, new List <IAttributeDefect> { new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec, Resolution = new LotDefectResolution() } }, new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec, Resolution = new LotDefectResolution() } }, })); Assert.IsNull(oldLot.LotStat); }
public void Returns_true_and_LotStat_will_have_been_set_if_a_single_unresolved_defect_exists_for_an_attribute() { var oldLot = new tblLot(); Assert.IsTrue(LotSyncHelper.SetProductSpecDefectStat(oldLot, new List <LotAttribute> { new LotAttribute { AttributeShortName = StaticAttributeNames.H2O.ShortName, AttributeValue = 1 }, }, new List <CustomerProductAttributeRange> { new CustomerProductAttributeRange { RangeMin = 2, RangeMax = 3, AttributeShortName = StaticAttributeNames.H2O.ShortName } }, new List <IAttributeDefect> { new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec, Resolution = new LotDefectResolution() } }, new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec } }, })); Assert.AreEqual((int)LotStat.Low_Water, oldLot.LotStat); }
private tblLot AddNewLot(ChileMaterialsReceived received, LotNumberResult lotNumber) { var lot = new tblLot { Lot = lotNumber, EmployeeID = received.ChileLot.Lot.EmployeeId, EntryDate = received.ChileLot.Lot.TimeStamp.ConvertUTCToLocal().RoundMillisecondsForSQL(), PTypeID = received.LotTypeId, Julian = lotNumber.Julian, BatchNum = received.LotDateSequence, BatchStatID = null, //looks like default value set in old context - RI 2/17/2014 TargetWgt = 0, //looks like default value set in old context - RI 2/17/2014 Notes = "Old Context Synchronization", }; OldContext.tblLots.AddObject(lot); return(lot); }