Azure Table Storage - C# Server SDK - TableEntity vs EntityData and TableController vs ApiController(annotated with MobileAppController) -


we in process of using azure mobile app providing offline-sync , push notifications support our android mobile app.

the sample project (todoitem) provided download uses entitydata , tablecontroller way implement. entitydata doesn't have notion of partitionkey , rowkey.

tableentity class has partitionkey , rowkey.

when start using build our model instead of entitydata, asked implement itabledata additionally - means definition of properties including 'id', 'version', 'updatedat', 'createdat', 'partitionkey' , 'rowkey'.

as developer using baas, not ask implement these things if use tableentity? there way use entitydata , still able specify partitionkey , rowkey?

any appreciated.

you can convert entitydata dynamictableentity , use when writing /reading azure table storage. while dynamictableentity conversion can assign entity partition key , row key want.

if not familiar how conversion between may @ nuget package: https://www.nuget.org/packages/objectflattenerrecomposer/

this takes object , converts entityproperty dictionary, can set pk , rk , create dynamic table entity.

i working azure team integrate api azure storage sdk: https://github.com/azure/azure-storage-net/pull/337/files

usage:

using objectflattenerrecomposer;

//flatten object , convert entityproperty dictionary

dictionary flattenedproperties = entitypropertyconverter.flatten(complexobject);

// create dynamictableentity , set pk , rk

dynamictableentity dynamictableentity = new dynamictableentity(partitionkey, rowkey);

dynamictableentity.properties = flattenedproperties;

// write dynamictableentity azure table storage using client sdk

//read entity azuretablestorage dynamictableentity using same pk , rk

dynamictableentity entity = [read azure using pk , rk];

//convert dynamictableentity original complex object.

imagine original complexobject of type order.

order order = entitypropertyconverter.convertback(entity.properties);


Comments