本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm类的典型用法代码示例。如果您正苦于以下问题:C# System.Data.Entity.Core.Metadata.Edm类的具体用法?C# System.Data.Entity.Core.Metadata.Edm怎么用?C# System.Data.Entity.Core.Metadata.Edm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Data.Entity.Core.Metadata.Edm类属于命名空间,在下文中一共展示了System.Data.Entity.Core.Metadata.Edm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_retrieve_properties
public void Can_retrieve_properties()
{
var entityType = new EntityType("ET", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", "S", "T", "Q", entityType);
var entityContainer = new EntityContainer("EC", DataSpace.SSpace);
entityContainer.AddEntitySetBase(entitySet);
var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());
var parameterBindings
= new[]
{
new ModificationFunctionParameterBinding(
new FunctionParameter(),
new ModificationFunctionMemberPath(Enumerable.Empty<EdmMember>(), null),
true)
};
var rowsAffectedParameter = new FunctionParameter("rows_affected", new TypeUsage(), ParameterMode.Out);
var resultBindings
= new[]
{
new ModificationFunctionResultBinding(
"C",
EdmProperty.CreatePrimitive(
"P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)))
};
var mapping
= new ModificationFunctionMapping(
entitySet, entityType, function,
parameterBindings, rowsAffectedParameter, resultBindings);
Assert.Same(rowsAffectedParameter, mapping.RowsAffectedParameter);
Assert.Same(function, mapping.Function);
Assert.Equal(parameterBindings, mapping.ParameterBindings);
Assert.Equal(resultBindings, mapping.ResultBindings);
}
示例2: BuildOutputVarMap
private static Dictionary<Var, md.EdmProperty> BuildOutputVarMap(PhysicalProjectOp projectOp, md.TypeUsage outputType)
{
var outputVarMap = new Dictionary<Var, md.EdmProperty>();
PlanCompiler.Assert(md.TypeSemantics.IsRowType(outputType), "PhysicalProjectOp result type is not a RowType?");
IEnumerator<md.EdmProperty> propertyEnumerator = TypeHelpers.GetEdmType<md.RowType>(outputType).Properties.GetEnumerator();
IEnumerator<Var> varEnumerator = projectOp.Outputs.GetEnumerator();
while (true)
{
var foundProp = propertyEnumerator.MoveNext();
var foundVar = varEnumerator.MoveNext();
if (foundProp != foundVar)
{
throw EntityUtil.InternalError(EntityUtil.InternalErrorCode.ColumnCountMismatch, 1, null);
}
if (!foundProp)
{
break;
}
outputVarMap[varEnumerator.Current] = propertyEnumerator.Current;
}
return outputVarMap;
}
示例3: GetEntitySetIdExpr
/// <summary>
/// Build out an expression corresponding to the entitysetid
/// </summary>
/// <param name="entitySetidProperty"> the property corresponding to the entitysetid </param>
/// <param name="op"> the *NewEntity op </param>
/// <returns> </returns>
private Node GetEntitySetIdExpr(md.EdmProperty entitySetIdProperty, NewEntityBaseOp op)
{
Node entitySetIdNode;
var entitySet = op.EntitySet;
if (entitySet != null)
{
var entitySetId = m_typeInfo.GetEntitySetId(entitySet);
var entitySetIdOp = m_command.CreateInternalConstantOp(md.Helper.GetModelTypeUsage(entitySetIdProperty), entitySetId);
entitySetIdNode = m_command.CreateNode(entitySetIdOp);
}
else
{
//
// Not in a view context; simply assume a null entityset
//
entitySetIdNode = CreateNullConstantNode(md.Helper.GetModelTypeUsage(entitySetIdProperty));
}
return entitySetIdNode;
}
示例4: GetNewType
/// <summary>
/// Get the "new" type corresponding to the input type.
/// For structured types, we simply look up the typeInfoMap
/// For collection types, we create a new collection type based on the
/// "new" element type.
/// For enums we return the underlying type of the enum type.
/// For strong spatial types we return the union type that includes the strong spatial type.
/// For all other types, we simply return the input type
/// </summary>
/// <param name="type"> </param>
/// <returns> </returns>
private md.TypeUsage GetNewType(md.TypeUsage type)
{
md.TypeUsage newType;
if (m_typeToNewTypeMap.TryGetValue(type, out newType))
{
return newType;
}
md.CollectionType collectionType;
if (TypeHelpers.TryGetEdmType(type, out collectionType))
{
// If this is a collection type, then clone a new collection type
var newElementType = GetNewType(collectionType.TypeUsage);
newType = TypeUtils.CreateCollectionType(newElementType);
}
else if (TypeUtils.IsStructuredType(type))
{
// structured type => we've already calculated the input
newType = m_typeInfo.GetTypeInfo(type).FlattenedTypeUsage;
}
else if (md.TypeSemantics.IsEnumerationType(type))
{
newType = TypeHelpers.CreateEnumUnderlyingTypeUsage(type);
}
else if (md.TypeSemantics.IsStrongSpatialType(type))
{
newType = TypeHelpers.CreateSpatialUnionTypeUsage(type);
}
else
{
// "simple" type => return the input type
newType = type;
}
// Add this information to the map
m_typeToNewTypeMap[type] = newType;
return newType;
}
示例5: BuildAccessor
/// <summary>
/// This function builds a "property accessor" over the input expression. It
/// can produce one of three results:
/// - It can return "null", if it is convinced that the input has no
/// such expression
/// - It can return a subnode of the input, if that subnode represents
/// the property
/// - Or, it can build a PropertyOp explicitly
/// Assertion: the property is not a structured type
/// </summary>
/// <param name="input"> The input expression </param>
/// <param name="property"> The desired property </param>
/// <returns> </returns>
private Node BuildAccessor(Node input, md.EdmProperty property)
{
var inputOp = input.Op;
// Special handling if the input is a NewRecordOp
var newRecordOp = inputOp as NewRecordOp;
if (null != newRecordOp)
{
int fieldPos;
// Identify the specific property we're interested in.
if (newRecordOp.GetFieldPosition(property, out fieldPos))
{
return Copy(input.Children[fieldPos]);
}
else
{
return null;
}
}
// special handling if the input is a null
if (inputOp.OpType
== OpType.Null)
{
return null;
}
// The default case: Simply return a new PropertyOp
var newPropertyOp = m_command.CreatePropertyOp(property);
return m_command.CreateNode(newPropertyOp, Copy(input));
}
示例6: TryGetDiscriminatorMap
// <summary>
// Tries to lookup custom discriminator map for the given type (applies to EntitySets with
// TPH discrimination pattern)
// </summary>
private bool TryGetDiscriminatorMap(md.EdmType type, out ExplicitDiscriminatorMap discriminatorMap)
{
discriminatorMap = null;
// check that there are actually discriminator maps available
if (null == m_discriminatorMaps)
{
return false;
}
// must be an entity type...
if (type.BuiltInTypeKind
!= md.BuiltInTypeKind.EntityType)
{
return false;
}
// get root entity type (discriminator maps are mapped from the root)
var rootEntityType = GetRootType((md.EntityType)type);
// find entity set
md.EntitySet entitySet;
if (!m_entityTypeToEntitySetMap.TryGetValue(rootEntityType, out entitySet))
{
return false;
}
// free floating entity constructors are stored with a null EntitySet
if (entitySet == null)
{
return false;
}
// look for discriminator map
return m_discriminatorMaps.TryGetValue(entitySet, out discriminatorMap);
}
示例7: RewriteAsCastToUnderlyingType
private Node RewriteAsCastToUnderlyingType(md.PrimitiveType underlyingType, CastOp op, Node n)
{
// if type of the argument and the underlying type match we can strip the Cast entirely
if (underlyingType.PrimitiveTypeKind
== ((md.PrimitiveType)n.Child0.Op.Type.EdmType).PrimitiveTypeKind)
{
return n.Child0;
}
else
{
return m_command.CreateNode(m_command.CreateCastOp(md.TypeUsage.Create(underlyingType, op.Type.Facets)), n.Child0);
}
}
示例8: FlattenComputedVar
private void FlattenComputedVar(ComputedVar v, Node node, out List<Node> newNodes, out md.TypeUsage newType)
{
newNodes = new List<Node>();
var definingExprNode = node.Child0; // defining expression for the VarDefOp
newType = null;
if (TypeUtils.IsCollectionType(v.Type))
{
PlanCompiler.Assert(definingExprNode.Op.OpType != OpType.Function, "Flattening of TVF output is not allowed.");
newType = GetNewType(v.Type);
Var newVar;
var newVarDefNode = m_command.CreateVarDefNode(definingExprNode, out newVar);
newNodes.Add(newVarDefNode);
m_varInfoMap.CreateCollectionVarInfo(v, newVar);
return;
}
// Get the "new" type for the Var
var typeInfo = m_typeInfo.GetTypeInfo(v.Type);
// Get a list of properties that we think are necessary
var desiredProperties = m_varPropertyMap[v];
var newVars = new List<Var>();
var newProps = new List<md.EdmProperty>();
newNodes = new List<Node>();
var hasNullSentinelVar = false;
foreach (var p in typeInfo.PropertyRefList)
{
// do I care for this property?
if (!desiredProperties.Contains(p))
{
continue;
}
var newProperty = typeInfo.GetNewProperty(p);
//
// #479467 - Make sure that we build Vars for all properties - if
// we are asked to produce all properties. This is extremely important
// for the top-level Vars
//
Node propAccessor = null;
if (desiredProperties.AllProperties)
{
propAccessor = BuildAccessorWithNulls(definingExprNode, newProperty);
}
else
{
propAccessor = BuildAccessor(definingExprNode, newProperty);
if (propAccessor == null)
{
continue;
}
}
// Add the new property
newProps.Add(newProperty);
// Create a new VarDefOp.
Var newVar;
var newVarDefNode = m_command.CreateVarDefNode(propAccessor, out newVar);
newNodes.Add(newVarDefNode);
newVars.Add(newVar);
// Check if it is a null sentinel var
if (!hasNullSentinelVar
&& IsNullSentinelPropertyRef(p))
{
hasNullSentinelVar = true;
}
}
m_varInfoMap.CreateStructuredVarInfo(v, typeInfo.FlattenedType, newVars, newProps, hasNullSentinelVar);
return;
}
示例9: TryGetNewProperty
/// <summary>
/// Try get the new property for the supplied propertyRef
/// </summary>
/// <param name="propertyRef"> property reference (on the old type) </param>
/// <param name="throwIfMissing"> throw if the property is not found </param>
/// <param name="newProperty"> the corresponding property on the new type </param>
/// <returns> </returns>
internal bool TryGetNewProperty(PropertyRef propertyRef, bool throwIfMissing, out md.EdmProperty newProperty)
{
return RootType.TryGetNewProperty(propertyRef, throwIfMissing, out newProperty);
}
示例10: GetNewType
// <summary>
// Get the "new" type corresponding to the input type. For structured types,
// we return the flattened record type.
// For collections of structured type, we return a new collection type of the corresponding flattened
// type.
// For enum types we return the underlying type of the enum type.
// For strong spatial types we return the union type that includes the strong spatial type.
// For everything else, we return the input type
// </summary>
// <param name="type"> the original type </param>
// <returns> the new type (if any) </returns>
private md.TypeUsage GetNewType(md.TypeUsage type)
{
if (TypeUtils.IsStructuredType(type))
{
var typeInfo = GetTypeInfo(type);
return typeInfo.FlattenedTypeUsage;
}
md.TypeUsage elementType;
if (TypeHelpers.TryGetCollectionElementType(type, out elementType))
{
var newElementType = GetNewType(elementType);
if (newElementType.EdmEquals(elementType))
{
return type;
}
else
{
return TypeHelpers.CreateCollectionTypeUsage(newElementType);
}
}
if (TypeUtils.IsEnumerationType(type))
{
return TypeHelpers.CreateEnumUnderlyingTypeUsage(type);
}
if (md.TypeSemantics.IsStrongSpatialType(type))
{
return TypeHelpers.CreateSpatialUnionTypeUsage(type);
}
// simple scalar
return type;
}
示例11: ExplodeType
// <summary>
// "Explode" a type. (ie) produce a flat record type with one property for each
// scalar property (top-level or nested) of the original type.
// Really deals with structured types, but also
// peels off collection wrappers
// </summary>
// <param name="type"> the type to explode </param>
// <returns> the typeinfo for this type (with the explosion) </returns>
private TypeInfo ExplodeType(md.TypeUsage type)
{
if (TypeUtils.IsStructuredType(type))
{
var typeInfo = GetTypeInfo(type);
ExplodeType(typeInfo);
return typeInfo;
}
if (TypeUtils.IsCollectionType(type))
{
var elementType = TypeHelpers.GetEdmType<md.CollectionType>(type).TypeUsage;
ExplodeType(elementType);
return null;
}
return null;
}
示例12: IsSpatialType_returns_true_for_all_spatial_types_only
public void IsSpatialType_returns_true_for_all_spatial_types_only()
{
var spatialTypes =
new[]
{
PrimitiveTypeKind.Geography,
PrimitiveTypeKind.Geometry,
PrimitiveTypeKind.GeometryPoint,
PrimitiveTypeKind.GeometryLineString,
PrimitiveTypeKind.GeometryPolygon,
PrimitiveTypeKind.GeometryMultiPoint,
PrimitiveTypeKind.GeometryMultiLineString,
PrimitiveTypeKind.GeometryMultiPolygon,
PrimitiveTypeKind.GeometryCollection,
PrimitiveTypeKind.GeographyPoint,
PrimitiveTypeKind.GeographyLineString,
PrimitiveTypeKind.GeographyPolygon,
PrimitiveTypeKind.GeographyMultiPoint,
PrimitiveTypeKind.GeographyMultiLineString,
PrimitiveTypeKind.GeographyMultiPolygon,
PrimitiveTypeKind.GeographyCollection,
};
foreach (var value in Enum.GetValues(typeof(PrimitiveTypeKind)).OfType<PrimitiveTypeKind>())
{
var mockType = new Mock<PrimitiveType>();
mockType.Setup(m => m.PrimitiveTypeKind).Returns(value);
Assert.Equal(spatialTypes.Contains(value), mockType.Object.IsSpatialType());
}
}
示例13: IsStructuredType
/// <summary>
/// Is this a structured type?
/// Note: Structured, in this context means structured outside the server.
/// UDTs for instance, are considered to be scalar types - all WinFS types,
/// would by this argument, be scalar types.
/// </summary>
/// <param name="type">The type to check</param>
/// <returns>true, if the type is a structured type</returns>
internal static bool IsStructuredType(md.TypeUsage type)
{
return (md.TypeSemantics.IsReferenceType(type) ||
md.TypeSemantics.IsRowType(type) ||
md.TypeSemantics.IsEntityType(type) ||
md.TypeSemantics.IsRelationshipType(type) ||
(md.TypeSemantics.IsComplexType(type)));
}
示例14: IsParentChildRelationship
/// <summary>
/// Is there a parent child relationship between table1 and table2 ?
/// </summary>
/// <param name="table1"> parent table ? </param>
/// <param name="table2"> child table ? </param>
/// <param name="constraints"> list of constraints ? </param>
/// <returns> true if there is at least one constraint </returns>
internal bool IsParentChildRelationship(
md.EntitySetBase table1, md.EntitySetBase table2,
out List<ForeignKeyConstraint> constraints)
{
LoadRelationships(table1.EntityContainer);
LoadRelationships(table2.EntityContainer);
var extentPair = new ExtentPair(table1, table2);
return m_parentChildRelationships.TryGetValue(extentPair, out constraints);
}
示例15: Create
private readonly RootTypeInfo m_rootType; // the top-most type in this types type hierarchy
#endregion
#region Constructors and factory methods
/// <summary>
/// Creates type information for a type
/// </summary>
/// <param name="type"> </param>
/// <param name="superTypeInfo"> </param>
/// <returns> </returns>
internal static TypeInfo Create(md.TypeUsage type, TypeInfo superTypeInfo, ExplicitDiscriminatorMap discriminatorMap)
{
TypeInfo result;
if (superTypeInfo == null)
{
result = new RootTypeInfo(type, discriminatorMap);
}
else
{
result = new TypeInfo(type, superTypeInfo);
}
return result;
}