我正在尝试使用lightswitch的General方法保存实体数据,即Lights。以下是以下代码。我无法弄清楚我错过了什么。代码或UI中没有错误。只是没有任何东西得救。
partial void viewFamilyProcessDatas_Updating(viewFamilyProcessData entity)
{
var AutoAddMissingListing = entity.AutoAddMissingListing;
var AutoAddOddLots = entity.AutoAddOddLots;
var DefaultFilterValue = entity.DefaultFilterValue;
var ExcludeZeroNumberOfUnits = entity.ExcludeZeroNumberOfUnits;
//objFamilyProcessData.FamilyID = entity.FamilyID;
var IgnoreForPricing = entity.IgnoreForPricing;
var LimitEndDate = entity.LimitEndDate;
var OffsetFromMaxAsAtDate = entity.OffsetFromMaxAsAtDate;
var PrefilterConstituents = entity.PrefilterConstituents;
var TimeDataExpires = entity.TimeDataExpires;
entity.AutoAddMissingListing = AutoAddMissingListing;
entity.AutoAddOddLots = AutoAddOddLots;
entity.DefaultFilterValue = DefaultFilterValue;
entity.ExcludeZeroNumberOfUnits = ExcludeZeroNumberOfUnits;
entity.IgnoreForPricing = IgnoreForPricing;
entity.LimitEndDate = LimitEndDate;
entity.OffsetFromMaxAsAtDate = OffsetFromMaxAsAtDate;
entity.PrefilterConstituents = PrefilterConstituents;
entity.TimeDataExpires = TimeDataExpires;
//this.DataWorkspace.SolaDBServerData.Details.DiscardChanges();
entity.Details.DiscardChanges();
}
答案 0 :(得分:0)
终于解决了这个问题:
partial void vwFamilyProcessDatas_Updating(vwFamilyProcessData entity)
{
if(entity.Details.EntityState.ToString() == "Modified")
{
var AutoAddMissingListing = entity.AutoAddMissingListing;
var AutoAddOddLots = entity.AutoAddOddLots;
var DefaultFilterValue = entity.DefaultFilterValue;
var ExcludeZeroNumberOfUnits = entity.ExcludeZeroNumberOfUnits;
var IgnoreForPricing = entity.IgnoreForPricing;
var LimitEndDate = entity.LimitEndDate;
var OffsetFromMaxAsAtDate = entity.OffsetFromMaxAsAtDate;
var PrefilterConstituents = entity.PrefilterConstituents;
var TimeDataExpires = entity.TimeDataExpires;
tblFamily objFamily = tblFamilies.Where(f => f.FamilyID == entity.FamilyID).Single();
objFamily.AutoAddMissingListing = AutoAddMissingListing;
objFamily.AutoAddOddLots = AutoAddOddLots;
objFamily.DefaultFilterValue = DefaultFilterValue;
objFamily.ExcludeZeroNumberOfUnits = ExcludeZeroNumberOfUnits;
objFamily.IgnoreForPricing = IgnoreForPricing;
objFamily.LimitEndDate = LimitEndDate;
objFamily.OffsetFromMaxAsAtDate = OffsetFromMaxAsAtDate;
objFamily.PrefilterConstituents = PrefilterConstituents;
objFamily.TimeDataExpires = TimeSpan.Parse(TimeDataExpires);
entity.Details.DiscardChanges();
}}