This question is locked. New answers and comments are not allowed.
I'm using the new domain model for my application, and so far I like it. I'm having a huge problem right now, though, where it appears that data is getting lost on the update.
I'm using the DataManager class that Telerik provides. My update service call looks like this:
The Telerik code for UpdateEntity looks like this:
The ExecuteCopy() method is correctly copying the data to the 'existingEntity' but somehow SaveChanges() is dropping the changes on the way to the database. For example, I had changed the value of TypeId but, as you can tell from my profiler, the TypeId (@p5) is set to NULL:
What would cause this to happen?
I'm using the DataManager class that Telerik provides. My update service call looks like this:
public void UpdatePattern(Pattern modelPattern)
{
using (var context = new DataManager(new DAL.MyContext()))
{
var dataPattern = new DAL.Pattern { ModifiedDate = DateTime.Now };
this.MapPatternModelToData(modelPattern, dataPattern);
context.UpdateEntity(dataPattern);
}
}
The Telerik code for UpdateEntity looks like this:
public string UpdateEntity<
T
>(T entity)
{
try
{
IObjectId id = Database.OID.GetObjectId(entity);
T existingEntity = _openAccessContext.GetObject<
T
>(new ObjectKey(id));
this.ExecuteCopy(entity, existingEntity);
this._openAccessContext.SaveChanges();
return id.ToString();
}
catch (OpenAccessException)
{
this._openAccessContext.ClearChanges();
throw;
}
}
The ExecuteCopy() method is correctly copying the data to the 'existingEntity' but somehow SaveChanges() is dropping the changes on the way to the database. For example, I had changed the value of TypeId but, as you can tell from my profiler, the TypeId (@p5) is set to NULL:
declare @p1 int
set @p1=7
exec sp_prepexec @p1 output,N'@p0 int,@p1 datetime,@p2 int,@p3 int,@p4 int,@p5 int,@p6 uniqueidentifier,@p7 int,@p8 uniqueidentifier',N'UPDATE [Pattern] SET [Measurement1Id]=@p0, [ModifiedDate]=@p1, [Measurement2Id]=@p2, [RangeId]=@p3, [FeatureId]=@p4, [TypeId]=@p5, [UniqueId]=@p6 WHERE [PatternId] = @p7 AND [Measurement2Id] is null AND [Measurement1Id] is null AND [RangeId] is null AND [FeatureId] is null AND [TypeId] is null AND [UniqueId]=@p8',@p0=NULL,@p1='2010-11-04 08:13:43:993',@p2=NULL,@p3=NULL,@p4=NULL,@p5=NULL,@p6='00000000-0000-0000-0000-000000000000',@p7=10,@p8='91958B38-DE5A-4E5A-B763-5316EB4EBB7D'
select @p1
What would cause this to happen?