本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmModel.FindDeclaredOperations方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.FindDeclaredOperations方法的具体用法?C# EdmModel.FindDeclaredOperations怎么用?C# EdmModel.FindDeclaredOperations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Edm.Library.EdmModel
的用法示例。
在下文中一共展示了EdmModel.FindDeclaredOperations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillStockContentsForEntityContainer
private void FillStockContentsForEntityContainer(IEdmEntityContainer edmContainer, IEdmModel edmModel, EdmModel stockModel)
{
var stockContainer = (EdmEntityContainer)stockModel.FindEntityContainer(edmContainer.FullName());
this.SetImmediateAnnotations(edmContainer, stockContainer, edmModel, stockModel);
foreach (var edmNavigationSource in edmContainer.Elements.OfType<IEdmNavigationSource>())
{
var stockEntityType = (EdmEntityType)stockModel.FindType(GetFullName(edmNavigationSource.EntityType()));
if (edmNavigationSource is IEdmSingleton)
{
stockContainer.AddSingleton(edmNavigationSource.Name, stockEntityType);
}
else
{
stockContainer.AddEntitySet(edmNavigationSource.Name, stockEntityType);
}
}
foreach (var stockNavigationSource in stockContainer.Elements.OfType<EdmNavigationSource>())
{
var stockEntityType = (EdmEntityType)stockModel.FindType(GetFullName(stockNavigationSource.EntityType()));
IEdmNavigationSource edmNavigationSource = edmContainer.FindEntitySet(stockNavigationSource.Name);
if (edmNavigationSource == null)
{
edmNavigationSource = edmContainer.FindSingleton(stockNavigationSource.Name);
}
var stockDerivedNavigations = GetAllNavigationFromDerivedTypesAndSelf(stockEntityType, stockModel);
foreach (var stockNavigationProperty in stockDerivedNavigations)
{
var edmNavigationProperty = edmNavigationSource.NavigationPropertyBindings.Select(n => n.NavigationProperty).SingleOrDefault(n => n.Name == stockNavigationProperty.Name);
if (edmNavigationProperty != null)
{
var targetEdmEntitySet = edmNavigationSource.FindNavigationTarget(edmNavigationProperty);
if (null != targetEdmEntitySet)
{
var targetEntitySetFromContainer = stockContainer.Elements.OfType<EdmEntitySet>().SingleOrDefault
(
n =>
GetBaseTypesAndSelf(((IEdmNavigationProperty)stockNavigationProperty).ToEntityType()).Select(m => GetFullName(m)).Contains(n.EntityType().FullName()) && n.Name == targetEdmEntitySet.Name
);
if (null == targetEntitySetFromContainer)
{
targetEntitySetFromContainer = stockContainer.Elements.OfType<EdmEntitySet>().SingleOrDefault
(
n =>
GetAllDerivedTypesAndSelf(((IEdmNavigationProperty)stockNavigationProperty).ToEntityType(), stockModel).Select(m => GetFullName(m)).Contains(n.EntityType().FullName()) && n.Name == targetEdmEntitySet.Name
);
}
stockNavigationSource.AddNavigationTarget(stockNavigationProperty, targetEntitySetFromContainer);
}
}
}
}
foreach (var edmOperationImport in edmContainer.OperationImports())
{
EdmOperationImport stockEdmOperationImport = null;
var edmActionImport = edmOperationImport as IEdmActionImport;
if (edmActionImport != null)
{
var newEdmAction = stockModel.FindDeclaredOperations(edmActionImport.Action.FullName()).OfType<IEdmAction>().FirstOrDefault() as EdmAction;
ExceptionUtilities.CheckObjectNotNull(newEdmAction, "cannot find action");
stockEdmOperationImport = stockContainer.AddActionImport(edmOperationImport.Name, newEdmAction, edmActionImport.EntitySet);
}
else
{
IEdmFunctionImport edmFunctionImport = edmOperationImport as IEdmFunctionImport;
ExceptionUtilities.CheckArgumentNotNull(edmFunctionImport, "edmFunctionImport");
var newEdmFunction = edmModel.FindDeclaredOperations(edmFunctionImport.Function.FullName()).OfType<IEdmFunction>().FirstOrDefault();
ExceptionUtilities.CheckObjectNotNull(newEdmFunction, "Expected to find an function: " + edmFunctionImport.Function.FullName());
stockEdmOperationImport = stockContainer.AddFunctionImport(edmFunctionImport.Name, newEdmFunction, edmFunctionImport.EntitySet, edmFunctionImport.IncludeInServiceDocument);
}
this.SetImmediateAnnotations(edmOperationImport, stockEdmOperationImport, edmModel, stockModel);
}
}