¿Cómo puedo actualizar los recursos de almacenamiento de tablas de Azure mediante la implementación de IDataServiceUpdateProvider?

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

Pregunta

Estoy tratando de exponer una mesa de Azure Storage Table editable. (Si es importante:. A Win Phone 7 a través del cliente OData Lib CTP) en el lado del servidor, tengo una DataServiceContext: TableServiceContext, IDataServiceUpdateProvider

Me puede agregar y objetos de borrado, pero cuando trato de actualizar un recurso, SaveChanges () no parece que "recoger" los valores que habían sido asignadas en las llamadas a 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();
    }

ACTUALIZACIÓN: La respuesta fue llamar updateObject () durante FijarValor ():

public void SetValue(object targetResource, string propertyName, object propertyValue)
    {
        var propInfo = targetResource.GetType().GetProperty(propertyName);
        propInfo.SetValue(targetResource, propertyValue, null);
        UpdateObject(targetResource);
    }
¿Fue útil?

Solución

ACTUALIZACIÓN: La respuesta fue llamar updateObject () durante FijarValor ():

FijarValor pública vacío (objeto targetResource, cadena nombrePropiedad, objeto propertyValue)     {         var propInfo = targetResource.GetType () GetProperty (propertyName).;         propInfo.SetValue (targetResource, propertyValue, null);         UpdateObject (targetResource);     }

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top