本文整理汇总了C#中DataServiceContext.SaveState方法的典型用法代码示例。如果您正苦于以下问题:C# DataServiceContext.SaveState方法的具体用法?C# DataServiceContext.SaveState怎么用?C# DataServiceContext.SaveState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataServiceContext
的用法示例。
在下文中一共展示了DataServiceContext.SaveState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
static public DataServiceState Save(DataServiceContext context, Dictionary<string,object> collections)
{
List<Type> knownTypes = GetKnownTypes(context);
Dictionary<EntityDescriptor, Guid> entityDescriptorToId;
ContextState contextState = context.SaveState(out entityDescriptorToId);
string contextAsString = SerializeContextToString(contextState, knownTypes);
var collectionsState = new Dictionary<string, CollectionState>();
if (collections != null)
{
foreach (KeyValuePair<string, object> kvp in collections)
{
IDataServiceCollection collection = (IDataServiceCollection) kvp.Value;
CollectionState collectionState = collection.SaveState(context, entityDescriptorToId);
collectionsState.Add(kvp.Key, collectionState);
}
}
DataServiceState state = new DataServiceState()
{
CollectionsState = collectionsState,
ContextAsString = contextAsString,
ContextTypeName = context.GetType().AssemblyQualifiedName,
KnownTypeNames = knownTypes.Select(t => t.AssemblyQualifiedName).ToList()
};
return state;
}