idataserviceupdateProviderを実装して、Azureテーブルストレージリソースを更新するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/3910988

質問

編集可能なAzureテーブルストレージテーブルを公開しようとしています。 (それが重要な場合:ODATAクライアントlib ctpを介して電話7を獲得すること。

オブジェクトを追加および削除することはできますが、リソースを更新しようとすると、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();
    }

更新:回答は、setValue()中にupdateObject()を呼び出すことでした。

public void SetValue(object targetResource, string propertyName, object propertyValue)
    {
        var propInfo = targetResource.GetType().GetProperty(propertyName);
        propInfo.SetValue(targetResource, propertyValue, null);
        UpdateObject(targetResource);
    }
役に立ちましたか?

解決

更新:回答は、setValue()中にupdateObject()を呼び出すことでした。

public void setValue(object targetResource、string propertyname、object propertyValue){var propinfo = targetResource.getType()。getProperty(propertyName); propinfo.setValue(ターゲットリソース、PropertyValue、null); updateObject(targetResource); }

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top