كيف يمكنني تحديث مورد تخزين جدول Azure عن طريق تطبيق IdatAserviceUpdateProvider؟
-
29-09-2019 - |
سؤال
أحاول فضح جدول تخزين طاولة Azure القابل للتحرير. (إذا كان من المهم: الفوز بالهاتف 7 عبر Odata Client Lib Ctp.) على جانب الخادم ، لدي dataserviceContext: tableServiceContex
يمكنني إضافة وحذف الكائنات ، ولكن عندما أحاول تحديث مورد ، لا يبدو أن Savechanges () "تلتقط" القيم التي تم تعيينها في المكالمات إلى SetProperty.
//Works fine
public object GetResource(IQueryable query, string fullTypeName)
{
var resource = query.Cast<MyDataModel>().SingleOrDefault();
if (fullTypeName != null && resource.GetType().FullName != fullTypeName)
{
throw new ApplicationException("Unexpected type for this resource");
}
return resource;
}
//Seems to work fine: gets called for each property.
public void SetValue(object targetResource, string propertyName, object propertyValue)
{
var propInfo = targetResource.GetType().GetProperty(propertyName);
propInfo.SetValue(targetResource, propertyValue, null);
}
//This gets called, but resource is not updated
void IUpdatable.SaveChanges()
{
//Forwarding from IUpdatable.SaveChanges() to DataServiceContext.SaveChanges()
base.SaveChanges();
}
تحديث: كان الجواب هو استدعاء updateObject () أثناء setValue ():
public void SetValue(object targetResource, string propertyName, object propertyValue)
{
var propInfo = targetResource.GetType().GetProperty(propertyName);
propInfo.SetValue(targetResource, propertyValue, null);
UpdateObject(targetResource);
}
المحلول
تحديث: كان الجواب هو استدعاء updateObject () أثناء setValue ():
public void setValue (Object TargetResource ، string propertyName ، Object PropertyValue) {var propinfo = targetResource.getType (). getProperty (propertyName) ؛ propinfo.setValue (TargetResource ، PropertyValue ، Null) ؛ updateObject (TargetResource) ؛ }
لا تنتمي إلى StackOverflow