本文整理汇总了C#中IEdmEntityType类的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityType类的具体用法?C# IEdmEntityType怎么用?C# IEdmEntityType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEdmEntityType类属于命名空间,在下文中一共展示了IEdmEntityType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CsdlSemanticsRecordExpression
public CsdlSemanticsRecordExpression(CsdlRecordExpression expression, IEdmEntityType bindingContext, CsdlSemanticsSchema schema) : base(schema, expression)
{
this.declaredTypeCache = new Cache<CsdlSemanticsRecordExpression, IEdmStructuredTypeReference>();
this.propertiesCache = new Cache<CsdlSemanticsRecordExpression, IEnumerable<IEdmPropertyConstructor>>();
this.expression = expression;
this.bindingContext = bindingContext;
}
示例2: ODataWriterCore
/// <summary>
/// Constructor.
/// </summary>
/// <param name="outputContext">The output context to write to.</param>
/// <param name="navigationSource">The navigation source we are going to write entities for.</param>
/// <param name="entityType">The entity type for the entries in the feed to be written (or null if the entity set base type should be used).</param>
/// <param name="writingFeed">True if the writer is created for writing a feed; false when it is created for writing an entry.</param>
/// <param name="listener">If not null, the writer will notify the implementer of the interface of relevant state changes in the writer.</param>
protected ODataWriterCore(
ODataOutputContext outputContext,
IEdmNavigationSource navigationSource,
IEdmEntityType entityType,
bool writingFeed,
IODataReaderWriterListener listener = null)
{
Debug.Assert(outputContext != null, "outputContext != null");
this.outputContext = outputContext;
this.writingFeed = writingFeed;
// create a collection validator when writing a top-level feed and a user model is present
if (this.writingFeed && this.outputContext.Model.IsUserModel())
{
this.feedValidator = new FeedWithoutExpectedTypeValidator();
}
if (navigationSource != null && entityType == null)
{
entityType = this.outputContext.EdmTypeResolver.GetElementType(navigationSource);
}
ODataUri odataUri = outputContext.MessageWriterSettings.ODataUri.Clone();
// Remove key for top level entry
if (!writingFeed && odataUri != null && odataUri.Path != null)
{
odataUri.Path = odataUri.Path.TrimEndingKeySegment();
}
this.listener = listener;
this.scopes.Push(new Scope(WriterState.Start, /*item*/null, navigationSource, entityType, /*skipWriting*/false, outputContext.MessageWriterSettings.SelectedProperties, odataUri));
}
示例3: CsdlSemanticsCollectionExpression
public CsdlSemanticsCollectionExpression(CsdlCollectionExpression expression, IEdmEntityType bindingContext, CsdlSemanticsSchema schema) : base(schema, expression)
{
this.declaredTypeCache = new Cache<CsdlSemanticsCollectionExpression, IEdmTypeReference>();
this.elementsCache = new Cache<CsdlSemanticsCollectionExpression, IEnumerable<IEdmExpression>>();
this.expression = expression;
this.bindingContext = bindingContext;
}
示例4: HasDefaultStream
public static bool HasDefaultStream(this IEdmModel model, IEdmEntityType entityType)
{
bool flag;
ExceptionUtils.CheckArgumentNotNull<IEdmModel>(model, "model");
ExceptionUtils.CheckArgumentNotNull<IEdmEntityType>(entityType, "entityType");
return (TryGetBooleanAnnotation(model, entityType, "HasStream", true, out flag) && flag);
}
示例5: ResolveKeys
public override IEnumerable<KeyValuePair<string, object>> ResolveKeys(
IEdmEntityType type,
IList<string> positionalValues,
Func<IEdmTypeReference, string, object> convertFunc)
{
return stringAsEnum.ResolveKeys(type, positionalValues, convertFunc);
}
示例6: EdmEntitySetBase
/// <summary>
/// Initializes a new instance of the <see cref="EdmEntitySetBase"/> class.
/// </summary>
/// <param name="name">Name of the entity set base.</param>
/// <param name="elementType">The entity type of the elements in this entity set base.</param>
protected EdmEntitySetBase(string name, IEdmEntityType elementType)
: base(name)
{
EdmUtil.CheckArgumentNull(elementType, "elementType");
this.type = new EdmCollectionType(new EdmEntityTypeReference(elementType, false));
}
示例7: CastPathSegment
/// <summary>
/// Initializes a new instance of the <see cref="CastPathSegment" /> class.
/// </summary>
/// <param name="previous">The previous segment in the path.</param>
/// <param name="castType">The type of the cast.</param>
public CastPathSegment(ODataPathSegment previous, IEdmEntityType castType)
: base(previous)
{
if (castType == null)
{
throw Error.ArgumentNull("cast");
}
IEdmType previousEdmType = previous.EdmType;
if (previousEdmType == null)
{
throw Error.InvalidOperation(SRResources.PreviousSegmentEdmTypeCannotBeNull);
}
if (previousEdmType.TypeKind == EdmTypeKind.Collection)
{
EdmType = castType.GetCollection();
}
else
{
EdmType = castType;
}
EntitySet = previous.EntitySet;
CastType = castType;
}
示例8: CsdlSemanticsPropertyReferenceExpression
public CsdlSemanticsPropertyReferenceExpression(CsdlPropertyReferenceExpression expression, IEdmEntityType bindingContext, CsdlSemanticsSchema schema) : base(schema, expression)
{
this.baseCache = new Cache<CsdlSemanticsPropertyReferenceExpression, IEdmExpression>();
this.elementCache = new Cache<CsdlSemanticsPropertyReferenceExpression, IEdmProperty>();
this.expression = expression;
this.bindingContext = bindingContext;
}
示例9: EntityPropertyMappingInfo
internal EntityPropertyMappingInfo(EntityPropertyMappingAttribute attribute, IEdmEntityType definingType, IEdmEntityType actualTypeDeclaringProperty)
{
this.attribute = attribute;
this.definingType = definingType;
this.actualPropertyType = actualTypeDeclaringProperty;
this.isSyndicationMapping = this.attribute.TargetSyndicationItem != SyndicationItemProperty.CustomProperty;
}
示例10: ValidateEntry
/// <summary>
/// Validates the type of an entry in a top-level feed.
/// </summary>
/// <param name="entityType">The type of the entry.</param>
internal void ValidateEntry(IEdmEntityType entityType)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(entityType != null, "entityType != null");
// If we don't have a type, store the type of the first item.
if (this.itemType == null)
{
this.itemType = entityType;
}
// Validate the expected and actual types.
if (this.itemType.IsEquivalentTo(entityType))
{
return;
}
// If the types are not equivalent, make sure they have a common base type.
IEdmType commonBaseType = EdmLibraryExtensions.GetCommonBaseType(this.itemType, entityType);
if (commonBaseType == null)
{
throw new ODataException(Strings.FeedWithoutExpectedTypeValidator_IncompatibleTypes(entityType.ODataFullName(), this.itemType.ODataFullName()));
}
this.itemType = (IEdmEntityType)commonBaseType;
}
示例11: 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="writeContext"/>.
/// </summary>
/// <param name="entityType">The entity type of the entry that would be written.</param>
/// <param name="writeContext">The serializer context to be used while creating the collection.</param>
/// <remarks>The default constructor is for unit testing only.</remarks>
public SelectExpandNode(IEdmEntityType entityType, ODataSerializerContext writeContext)
: this(writeContext.SelectExpandClause, entityType, writeContext.Model)
{
var queryOptionParser = new ODataQueryOptionParser(
writeContext.Model,
entityType,
writeContext.NavigationSource,
_extraQueryParameters);
var selectExpandClause = queryOptionParser.ParseSelectAndExpand();
if (selectExpandClause != null)
{
foreach (SelectItem selectItem in selectExpandClause.SelectedItems)
{
ExpandedNavigationSelectItem expandItem = selectItem as ExpandedNavigationSelectItem;
if (expandItem != null)
{
ValidatePathIsSupported(expandItem.PathToNavigationProperty);
NavigationPropertySegment navigationSegment = (NavigationPropertySegment)expandItem.PathToNavigationProperty.LastSegment;
IEdmNavigationProperty navigationProperty = navigationSegment.NavigationProperty;
if (!ExpandedNavigationProperties.ContainsKey(navigationProperty))
{
ExpandedNavigationProperties.Add(navigationProperty, expandItem.SelectAndExpand);
}
}
}
}
SelectedNavigationProperties.ExceptWith(ExpandedNavigationProperties.Keys);
}
示例12: SelectExpandQueryOption
/// <summary>
/// Initializes a new instance of the <see cref="SelectExpandQueryOption"/> class.
/// </summary>
/// <param name="select">The $select query parameter value.</param>
/// <param name="expand">The $select query parameter value.</param>
/// <param name="context">The <see cref="ODataQueryContext"/> which contains the <see cref="IEdmModel"/> and some type information.</param>
public SelectExpandQueryOption(string select, string expand, ODataQueryContext context)
{
if (context == null)
{
throw Error.ArgumentNull("context");
}
if (String.IsNullOrEmpty(select) && String.IsNullOrEmpty(expand))
{
throw Error.Argument(SRResources.SelectExpandEmptyOrNull);
}
IEdmEntityType entityType = context.ElementType as IEdmEntityType;
if (entityType == null)
{
throw Error.Argument("context", SRResources.SelectNonEntity, context.ElementType.ToTraceString());
}
_entityType = entityType;
Context = context;
RawSelect = select;
RawExpand = expand;
Validator = new SelectExpandQueryValidator();
}
示例13: EdmDeltaModel
public EdmDeltaModel(IEdmModel source, IEdmEntityType entityType, IEnumerable<string> propertyNames)
{
_source = source;
_entityType = new EdmEntityType(entityType.Namespace, entityType.Name);
foreach (var property in entityType.StructuralProperties())
{
if (propertyNames.Contains(property.Name))
_entityType.AddStructuralProperty(property.Name, property.Type, property.DefaultValueString, property.ConcurrencyMode);
}
foreach (var property in entityType.NavigationProperties())
{
if (propertyNames.Contains(property.Name))
{
var navInfo = new EdmNavigationPropertyInfo()
{
ContainsTarget = property.ContainsTarget,
DependentProperties = property.DependentProperties(),
PrincipalProperties = property.PrincipalProperties(),
Name = property.Name,
OnDelete = property.OnDelete,
Target = property.Partner != null
? property.Partner.DeclaringEntityType()
: property.Type.TypeKind() == EdmTypeKind.Collection
? (property.Type.Definition as IEdmCollectionType).ElementType.Definition as IEdmEntityType
: property.Type.TypeKind() == EdmTypeKind.Entity
? property.Type.Definition as IEdmEntityType
: null,
TargetMultiplicity = property.TargetMultiplicity(),
};
_entityType.AddUnidirectionalNavigation(navInfo);
}
}
}
示例14: CreateODataEntry
/// <summary>
/// Creates a new ODataEntry from the specified entity set, instance, and type.
/// </summary>
/// <param name="entitySet">Entity set for the new entry.</param>
/// <param name="value">Entity instance for the new entry.</param>
/// <param name="entityType">Entity type for the new entry.</param>
/// <returns>New ODataEntry with the specified entity set and type, property values from the specified instance.</returns>
internal static ODataEntry CreateODataEntry(IEdmEntitySet entitySet, IEdmStructuredValue value, IEdmEntityType entityType)
{
var entry = new ODataEntry();
entry.SetAnnotation(new ODataTypeAnnotation(entitySet, entityType));
entry.Properties = value.PropertyValues.Select(p =>
{
object propertyValue;
if (p.Value.ValueKind == EdmValueKind.Null)
{
propertyValue = null;
}
else if (p.Value is IEdmPrimitiveValue)
{
propertyValue = ((IEdmPrimitiveValue)p.Value).ToClrValue();
}
else
{
Assert.Fail("Test only currently supports creating ODataEntry from IEdmPrimitiveValue instances.");
return null;
}
return new ODataProperty() { Name = p.Name, Value = propertyValue };
});
return entry;
}
示例15: GetIdentifierPrefix
private string GetIdentifierPrefix(IEdmEntityType entityType)
{
if (entityType.BaseEntityType() != null)
{
return GetIdentifierPrefix(entityType.BaseEntityType());
}
TypeMapping existingMapping;
if (_typeUriMap.TryGetValue(entityType.FullName(), out existingMapping))
{
return existingMapping.IdentifierPrefix;
}
var keyList = entityType.DeclaredKey.ToList();
if (keyList.Count != 1)
{
// Ignore this entity
// TODO: Log an error
return null;
}
var identifierPrefix = GetStringAnnotationValue(keyList.First(), AnnotationsNamespace, "IdentifierPrefix");
if (identifierPrefix == null)
{
// TODO: Log an error
}
return identifierPrefix;
}