本文整理汇总了C#中MetadataWorkspace.TryGetEntityContainer方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataWorkspace.TryGetEntityContainer方法的具体用法?C# MetadataWorkspace.TryGetEntityContainer怎么用?C# MetadataWorkspace.TryGetEntityContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataWorkspace
的用法示例。
在下文中一共展示了MetadataWorkspace.TryGetEntityContainer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyExtent
// Verifies the given extent is present in the given workspace.
private static void VerifyExtent(MetadataWorkspace workspace, EntitySetBase extent)
{
// get the container to which the given extent belongs
EntityContainer actualContainer = extent.EntityContainer;
// try to retrieve the container in the given workspace
EntityContainer referenceContainer = null;
if (null != actualContainer)
{
workspace.TryGetEntityContainer(
actualContainer.Name, actualContainer.DataSpace, out referenceContainer);
}
// determine if the given extent lives in a container from the given workspace
// (the item collections for each container are reference equivalent when they are declared in the
// same item collection)
if (null == actualContainer || null == referenceContainer ||
!Object.ReferenceEquals(actualContainer, referenceContainer))
{
//
throw EntityUtil.Update(System.Data.Entity.Strings.Update_WorkspaceMismatch, null);
}
}
示例2: FindFunctionImport
// requires: all arguments must be given
internal static EdmFunction FindFunctionImport(MetadataWorkspace workspace, string containerName, string functionImportName)
{
Debug.Assert(null != workspace && null != containerName && null != functionImportName);
// find entity container
EntityContainer entityContainer;
if (!workspace.TryGetEntityContainer(containerName, DataSpace.CSpace, out entityContainer))
{
throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_UnableToFindFunctionImportContainer(
containerName));
}
// find function import
EdmFunction functionImport = null;
foreach (EdmFunction candidate in entityContainer.FunctionImports)
{
if (candidate.Name == functionImportName)
{
functionImport = candidate;
break;
}
}
if (null == functionImport)
{
throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_UnableToFindFunctionImport(
containerName, functionImportName));
}
if (functionImport.IsComposableAttribute)
{
throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.EntityClient_FunctionImportMustBeNonComposable(containerName + "." + functionImportName));
}
return functionImport;
}
示例3: FindFunctionImport
// requires: all arguments must be given
internal static EdmFunction FindFunctionImport(MetadataWorkspace workspace, string containerName, string functionImportName)
{
DebugCheck.NotNull(workspace);
DebugCheck.NotNull(containerName);
DebugCheck.NotNull(functionImportName);
// find entity container
EntityContainer entityContainer;
if (!workspace.TryGetEntityContainer(containerName, DataSpace.CSpace, out entityContainer))
{
throw new InvalidOperationException(
Strings.EntityClient_UnableToFindFunctionImportContainer(
containerName));
}
// find function import
EdmFunction functionImport = null;
foreach (var candidate in entityContainer.FunctionImports)
{
if (candidate.Name == functionImportName)
{
functionImport = candidate;
break;
}
}
if (null == functionImport)
{
throw new InvalidOperationException(
Strings.EntityClient_UnableToFindFunctionImport(
containerName, functionImportName));
}
if (functionImport.IsComposableAttribute)
{
throw new InvalidOperationException(
Strings.EntityClient_FunctionImportMustBeNonComposable(containerName + "." + functionImportName));
}
return functionImport;
}