Wie kann ich durch die Implementierung IDataServiceUpdateProvider Azure Table Speicherressourcen aktualisieren?

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

Frage

Ich versuche, eine bearbeitbare Azure Tabellen Speicher Tabelle zu belichten. (Wenn es darauf ankommt. Sieg Phone 7 über den OData-Client Lib CTP) Auf der Serverseite habe ich ein Dataservicecontext: TableServiceContext, IDataServiceUpdateProvider

kann ich hinzufügen und löschen Objekte, aber wenn ich versuche, eine Ressource zu aktualisieren, Savechanges () scheint nicht zu „Pick up“ die Werte, die in den Aufrufen von SetProperty zugewiesen worden war.

//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();
    }

UPDATE: Antwort war Update () während SetValue () aufzurufen:

public void SetValue(object targetResource, string propertyName, object propertyValue)
    {
        var propInfo = targetResource.GetType().GetProperty(propertyName);
        propInfo.SetValue(targetResource, propertyValue, null);
        UpdateObject(targetResource);
    }
War es hilfreich?

Lösung

UPDATE: Antwort war Update () während SetValue () aufzurufen:

public void SetValue (Objekt targetResource, string Eigenschaftsname, Objekt property)     {         var PROPINFO = targetResource.GetType () GetProperty (property.);         propInfo.SetValue (targetResource, property, null);         Update (targetResource);     }

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top