本文整理汇总了C#中IEdmEntityTypeReference.EntityDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityTypeReference.EntityDefinition方法的具体用法?C# IEdmEntityTypeReference.EntityDefinition怎么用?C# IEdmEntityTypeReference.EntityDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmEntityTypeReference
的用法示例。
在下文中一共展示了IEdmEntityTypeReference.EntityDefinition方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EntityInstanceContext
private EntityInstanceContext(ODataSerializerContext serializerContext, IEdmEntityTypeReference entityType, IEdmStructuredObject edmObject)
{
if (serializerContext == null)
{
throw Error.ArgumentNull("serializerContext");
}
SerializerContext = serializerContext;
EntityType = entityType.EntityDefinition();
EdmObject = edmObject;
}
示例2: EntityInstanceContext
private EntityInstanceContext(ODataSerializerContext serializerContext, IEdmEntityTypeReference entityType, IEdmEntityObject edmObject, string assemblyName)
{
if (serializerContext == null)
{
throw Error.ArgumentNull("serializerContext");
}
AssemblyName = assemblyName;
SerializerContext = serializerContext;
EntityType = entityType.EntityDefinition();
EdmObject = edmObject;
}
示例3: SelectExpandNode
/// <summary>
/// Creates a new instance of the <see cref="SelectExpandNode"/> class describing the set of structural properties,
/// navigation properties, and actions to select and expand for the given <paramref name="selectExpandClause"/>.
/// </summary>
/// <param name="selectExpandClause">The parsed $select and $expand query options.</param>
/// <param name="entityType">The entity type of the entry that would be written.</param>
/// <param name="model">The <see cref="IEdmModel"/> that contains the given entity type.</param>
public SelectExpandNode(SelectExpandClause selectExpandClause, IEdmEntityTypeReference entityType, IEdmModel model)
: this()
{
if (entityType == null)
{
throw Error.ArgumentNull("entityType");
}
if (model == null)
{
throw Error.ArgumentNull("model");
}
HashSet<IEdmStructuralProperty> allStructuralProperties = new HashSet<IEdmStructuralProperty>(entityType.StructuralProperties());
HashSet<IEdmNavigationProperty> allNavigationProperties = new HashSet<IEdmNavigationProperty>(entityType.NavigationProperties());
HashSet<IEdmFunctionImport> allActions = new HashSet<IEdmFunctionImport>(model.GetAvailableProcedures(entityType.EntityDefinition()));
if (selectExpandClause == null)
{
SelectedStructuralProperties = allStructuralProperties;
SelectedNavigationProperties = allNavigationProperties;
SelectedActions = allActions;
}
else
{
if (selectExpandClause.AllSelected)
{
SelectedStructuralProperties = allStructuralProperties;
SelectedNavigationProperties = allNavigationProperties;
SelectedActions = allActions;
}
else
{
BuildSelections(selectExpandClause, allStructuralProperties, allNavigationProperties, allActions);
}
BuildExpansions(selectExpandClause, allNavigationProperties);
// remove expanded navigation properties from the selected navigation properties.
SelectedNavigationProperties.ExceptWith(ExpandedNavigationProperties.Keys);
}
}
示例4: ReadEntry
/// <summary>
/// Deserializes the given <paramref name="entryWrapper"/> under the given <paramref name="readContext"/>.
/// </summary>
/// <param name="entryWrapper">The OData entry to deserialize.</param>
/// <param name="entityType">The entity type of the entry to deserialize.</param>
/// <param name="readContext">The deserializer context.</param>
/// <returns>The deserialized entity.</returns>
public virtual object ReadEntry(ODataEntryWithNavigationLinks entryWrapper, IEdmEntityTypeReference entityType,
ODataDeserializerContext readContext)
{
if (entryWrapper == null)
{
throw Error.ArgumentNull("entryWrapper");
}
if (readContext == null)
{
throw Error.ArgumentNull("readContext");
}
if (!String.IsNullOrEmpty(entryWrapper.Entry.TypeName) && entityType.FullName() != entryWrapper.Entry.TypeName)
{
// received a derived type in a base type deserializer. delegate it to the appropriate derived type deserializer.
IEdmModel model = readContext.Model;
if (model == null)
{
throw Error.Argument("readContext", SRResources.ModelMissingFromReadContext);
}
IEdmEntityType actualType = model.FindType(entryWrapper.Entry.TypeName) as IEdmEntityType;
if (actualType == null)
{
throw new ODataException(Error.Format(SRResources.EntityTypeNotInModel, entryWrapper.Entry.TypeName));
}
if (actualType.IsAbstract)
{
string message = Error.Format(SRResources.CannotInstantiateAbstractEntityType, entryWrapper.Entry.TypeName);
throw new ODataException(message);
}
IEdmTypeReference actualEntityType = new EdmEntityTypeReference(actualType, isNullable: false);
ODataEdmTypeDeserializer deserializer = DeserializerProvider.GetEdmTypeDeserializer(actualEntityType);
if (deserializer == null)
{
throw new SerializationException(
Error.Format(SRResources.TypeCannotBeDeserialized, actualEntityType.FullName(), typeof(ODataMediaTypeFormatter).Name));
}
object resource = deserializer.ReadInline(entryWrapper, actualEntityType, readContext);
EdmStructuredObject structuredObject = resource as EdmStructuredObject;
if (structuredObject != null)
{
structuredObject.ExpectedEdmType = entityType.EntityDefinition();
}
return resource;
}
else
{
object resource = CreateEntityResource(entityType, readContext);
ApplyEntityProperties(resource, entryWrapper, entityType, readContext);
return resource;
}
}
示例5: EdmEntityObject
/// <summary>
/// Initializes a new instance of the <see cref="EdmStructuredObject"/> class.
/// </summary>
/// <param name="edmType">The <see cref="IEdmEntityTypeReference"/> of this object.</param>
public EdmEntityObject(IEdmEntityTypeReference edmType)
: this(edmType.EntityDefinition(), edmType.IsNullable)
{
}
示例6: EdmEntityObject
/// <summary>
/// Initializes a new instance of the <see cref="EdmStructuredObject"/> class.
/// </summary>
/// <param name="edmType">The <see cref="IEdmEntityTypeReference"/> of this object.</param>
/// <param name="assembliesResolver">The assemblies resolve to use for type resolution</param>
public EdmEntityObject(IEdmEntityTypeReference edmType, AssembliesResolver assembliesResolver)
: this(edmType.EntityDefinition(), assembliesResolver, edmType.IsNullable)
{
}
示例7: ProcessEntityTypeReference
protected override void ProcessEntityTypeReference(IEdmEntityTypeReference element)
{
this.CheckSchemaElementReference(element.EntityDefinition());
}
示例8: EdmDeltaDeletedEntityObject
/// <summary>
/// Initializes a new instance of the <see cref="EdmDeltaDeletedEntityObject"/> class.
/// </summary>
/// <param name="entityTypeReference">The <see cref="IEdmEntityTypeReference"/> of this DeltaDeletedEntityObject.</param>
public EdmDeltaDeletedEntityObject(IEdmEntityTypeReference entityTypeReference, AssembliesResolver assembliesResolver)
: this(entityTypeReference.EntityDefinition(), assembliesResolver, entityTypeReference.IsNullable)
{
}
示例9: EdmDeltaDeletedLink
/// <summary>
/// Initializes a new instance of the <see cref="EdmDeltaDeletedLink"/> class.
/// </summary>
/// <param name="entityTypeReference">The <see cref="IEdmEntityTypeReference"/> of this DeltaDeletedLink.</param>
public EdmDeltaDeletedLink(IEdmEntityTypeReference entityTypeReference)
: this(entityTypeReference.EntityDefinition(), entityTypeReference.IsNullable)
{
}
示例10: EdmDeltaEntityObject
/// <summary>
/// Initializes a new instance of the <see cref="EdmDeltaEntityObject"/> class.
/// </summary>
/// <param name="entityTypeReference">The <see cref="IEdmEntityTypeReference"/> of this DeltaEntityObject.</param>
public EdmDeltaEntityObject(IEdmEntityTypeReference entityTypeReference)
: this(entityTypeReference.EntityDefinition(), entityTypeReference.IsNullable)
{
}
示例11: BuildEdmModel
private void BuildEdmModel()
{
_entityType = new EdmEntityTypeReference(new EdmEntityType("NS", "Entity"), isNullable: false);
_derivedEntityType = new EdmEntityTypeReference(new EdmEntityType("NS", "DerivedEntity", _entityType.EntityDefinition()), isNullable: false);
var entityCollection = new EdmCollectionTypeReference(new EdmCollectionType(_entityType));
var derivedEntityCollection = new EdmCollectionTypeReference(new EdmCollectionType(_derivedEntityType));
EdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Name");
model.AddElement(container);
// non-bindable action
container.AddActionImport(new EdmAction("NS", "NonBindableAction", returnType: null));
// action bound to entity
var actionBoundToEntity = new EdmAction(
"NS",
"ActionBoundToEntity",
returnType: null,
isBound: true,
entitySetPathExpression: null);
actionBoundToEntity.AddParameter("bindingParameter", _entityType);
model.AddElement(actionBoundToEntity);
// action bound to derived entity
var actionBoundToDerivedEntity = new EdmAction(
"NS",
"ActionBoundToDerivedEntity",
returnType: null,
isBound: true,
entitySetPathExpression: null);
actionBoundToDerivedEntity.AddParameter("bindingParameter", _derivedEntityType);
model.AddElement(actionBoundToDerivedEntity);
// action bound to entity collection
var actionBoundToEntityCollection = new EdmAction(
"NS",
"ActionBoundToEntityCollection",
returnType: null,
isBound: true,
entitySetPathExpression: null);
actionBoundToEntityCollection.AddParameter("bindingParameter", entityCollection);
model.AddElement(actionBoundToEntityCollection);
// action bound to derived entity collection
var actionBoundToDerivedEntityCollection = new EdmAction(
"NS",
"ActionBoundToDerivedEntityCollection",
returnType: null,
isBound: true,
entitySetPathExpression: null);
actionBoundToDerivedEntityCollection.AddParameter("bindingParameter", derivedEntityCollection);
model.AddElement(actionBoundToDerivedEntityCollection);
// ambiguos actions
container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));
container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));
IEdmTypeReference returnType = new EdmPrimitiveTypeReference(
EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32), false);
// non-bindable function
container.AddFunctionImport(new EdmFunction("NS", "NonBindableFunction", returnType));
// function bound to entity
var functionBoundToEntity = new EdmFunction(
"NS",
"FunctionBoundToEntity",
returnType,
isBound: true,
entitySetPathExpression: null,
isComposable: false);
functionBoundToEntity.AddParameter("bindingParameter", _entityType);
model.AddElement(functionBoundToEntity);
// function bound to entity
var functionBoundToDerivedEntity = new EdmFunction(
"NS",
"FunctionBoundToDerivedEntity",
returnType,
isBound: true,
entitySetPathExpression: null,
isComposable: false);
functionBoundToDerivedEntity.AddParameter("bindingParameter", _derivedEntityType);
model.AddElement(functionBoundToDerivedEntity);
// function bound to entity collection
var functionBoundToEntityCollection = new EdmFunction(
"NS",
"FunctionBoundToEntityCollection",
returnType,
isBound: true,
entitySetPathExpression: null,
isComposable: false);
functionBoundToEntityCollection.AddParameter("bindingParameter", entityCollection);
model.AddElement(functionBoundToEntityCollection);
// function bound to derived entity collection
var functionBoundToDerivedEntityCollection = new EdmFunction(
"NS",
//.........这里部分代码省略.........
示例12: ValidateEntityTypeIsAssignable
/// <summary>
/// Validates that the <paramref name="payloadEntityTypeReference"/> is assignable to the <paramref name="expectedEntityTypeReference"/>
/// and fails if it's not.
/// </summary>
/// <param name="expectedEntityTypeReference">The expected entity type reference, the base type of the entities expected.</param>
/// <param name="payloadEntityTypeReference">The payload entity type reference to validate.</param>
internal static void ValidateEntityTypeIsAssignable(IEdmEntityTypeReference expectedEntityTypeReference, IEdmEntityTypeReference payloadEntityTypeReference)
{
Debug.Assert(expectedEntityTypeReference != null, "expectedEntityTypeReference != null");
Debug.Assert(payloadEntityTypeReference != null, "payloadEntityTypeReference != null");
// Entity types must be assignable
if (!EdmLibraryExtensions.IsAssignableFrom(expectedEntityTypeReference.EntityDefinition(), payloadEntityTypeReference.EntityDefinition()))
{
throw new ODataException(Strings.ValidationUtils_EntryTypeNotAssignableToExpectedType(payloadEntityTypeReference.ODataFullName(), expectedEntityTypeReference.ODataFullName()));
}
}
示例13: ValidateEntityTypeIsAssignable
internal static void ValidateEntityTypeIsAssignable(IEdmEntityTypeReference expectedEntityTypeReference, IEdmEntityTypeReference payloadEntityTypeReference)
{
if (!expectedEntityTypeReference.EntityDefinition().IsAssignableFrom(payloadEntityTypeReference.EntityDefinition()))
{
throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_EntryTypeNotAssignableToExpectedType(payloadEntityTypeReference.ODataFullName(), expectedEntityTypeReference.ODataFullName()));
}
}
示例14: BuildSelections
private void BuildSelections(Selection selection, IEdmEntityTypeReference entityType, IEdmModel model)
{
Contract.Assert(entityType != null);
Contract.Assert(model != null);
HashSet<IEdmStructuralProperty> allStructuralProperties = new HashSet<IEdmStructuralProperty>(entityType.StructuralProperties());
HashSet<IEdmNavigationProperty> allNavigationProperties = new HashSet<IEdmNavigationProperty>(entityType.NavigationProperties());
HashSet<IEdmFunctionImport> allActions = new HashSet<IEdmFunctionImport>(model.GetAvailableProcedures(entityType.EntityDefinition()));
if (selection == null || selection == AllSelection.Instance)
{
SelectedStructuralProperties = allStructuralProperties;
SelectedNavigationProperties = allNavigationProperties;
SelectedActions = allActions;
}
else if (selection == ExpansionsOnly.Instance)
{
// nothing to select.
}
else
{
PartialSelection partialSelection = selection as PartialSelection;
if (partialSelection == null)
{
throw new ODataException(Error.Format(SRResources.SelectionTypeNotSupported, selection.GetType().Name));
}
HashSet<IEdmStructuralProperty> selectedStructuralProperties = new HashSet<IEdmStructuralProperty>();
HashSet<IEdmNavigationProperty> selectedNavigationProperties = new HashSet<IEdmNavigationProperty>();
HashSet<IEdmFunctionImport> selectedActions = new HashSet<IEdmFunctionImport>();
foreach (SelectionItem selectionItem in partialSelection.SelectedItems)
{
PathSelectionItem pathSelection = selectionItem as PathSelectionItem;
if (pathSelection != null)
{
ValidatePathIsSupported(pathSelection.SelectedPath);
Segment segment = pathSelection.SelectedPath.LastSegment;
NavigationPropertySegment navigationPropertySegment = segment as NavigationPropertySegment;
if (navigationPropertySegment != null)
{
if (allNavigationProperties.Contains(navigationPropertySegment.NavigationProperty))
{
selectedNavigationProperties.Add(navigationPropertySegment.NavigationProperty);
}
continue;
}
PropertySegment structuralPropertySegment = segment as PropertySegment;
if (structuralPropertySegment != null)
{
if (allStructuralProperties.Contains(structuralPropertySegment.Property))
{
selectedStructuralProperties.Add(structuralPropertySegment.Property);
}
continue;
}
throw new ODataException(Error.Format(SRResources.SelectionTypeNotSupported, segment.GetType().Name));
}
WildcardSelectionItem wildCardSelection = selectionItem as WildcardSelectionItem;
if (wildCardSelection != null)
{
selectedStructuralProperties = allStructuralProperties;
selectedNavigationProperties = allNavigationProperties;
continue;
}
ContainerQualifiedWildcardSelectionItem wildCardActionSelection = selectionItem as ContainerQualifiedWildcardSelectionItem;
if (wildCardActionSelection != null)
{
IEnumerable<IEdmFunctionImport> actionsInThisContainer = allActions.Where(a => a.Container == wildCardActionSelection.Container);
foreach (IEdmFunctionImport action in actionsInThisContainer)
{
selectedActions.Add(action);
}
continue;
}
throw new ODataException(Error.Format(SRResources.SelectionTypeNotSupported, selectionItem.GetType().Name));
}
SelectedStructuralProperties = selectedStructuralProperties;
SelectedNavigationProperties = selectedNavigationProperties;
SelectedActions = selectedActions;
}
}