当前位置: 首页>>代码示例>>C#>>正文


C# Metadata.Edm类代码示例

本文整理汇总了C#中System.Data.Metadata.Edm的典型用法代码示例。如果您正苦于以下问题:C# System.Data.Metadata.Edm类的具体用法?C# System.Data.Metadata.Edm怎么用?C# System.Data.Metadata.Edm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Data.Metadata.Edm类属于命名空间,在下文中一共展示了System.Data.Metadata.Edm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyEdmTypesEquivalent

        public static void VerifyEdmTypesEquivalent(LegacyMetadata.EdmType legacyEdmType, EdmType edmType)
        {
            Assert.Equal(legacyEdmType.FullName, edmType.FullName);

            Assert.True(
                (legacyEdmType.BaseType == null && edmType.BaseType == null) ||
                legacyEdmType.BaseType.FullName == edmType.BaseType.FullName);
            Assert.Equal(legacyEdmType.BuiltInTypeKind.ToString(), edmType.BuiltInTypeKind.ToString());
            Assert.Equal(
                ((LegacyMetadata.DataSpace)typeof(LegacyMetadata.EdmType)
                                               .GetProperty("DataSpace", BindingFlags.Instance | BindingFlags.NonPublic)
                                               .GetValue(legacyEdmType)).ToString(),
                ((DataSpace)typeof(EdmType)
                                .GetProperty("DataSpace", BindingFlags.Instance | BindingFlags.NonPublic)
                                .GetValue(edmType)).ToString());

            if (edmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveTypeKind)
            {
                var prmitiveEdmType = (PrimitiveType)edmType;
                var legacyPrmitiveEdmType = (LegacyMetadata.PrimitiveType)legacyEdmType;

                // EF5 geospatial types should be converted to EF6 spatial types
                var expectedClrEquivalentType =
                    legacyPrmitiveEdmType.ClrEquivalentType == typeof(LegacySpatial.DbGeography)
                        ? typeof(DbGeography)
                        : legacyPrmitiveEdmType.ClrEquivalentType == typeof(LegacySpatial.DbGeometry)
                              ? typeof(DbGeometry)
                              : legacyPrmitiveEdmType.ClrEquivalentType;

                Assert.Equal(expectedClrEquivalentType, prmitiveEdmType.ClrEquivalentType);
                Assert.Equal(legacyPrmitiveEdmType.GetEdmPrimitiveType().FullName, prmitiveEdmType.GetEdmPrimitiveType().FullName);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:33,代码来源:TypeUsageVerificationHelper.cs

示例2: VerifyFacetsEquivalent

        public static void VerifyFacetsEquivalent(LegacyMetadata.Facet legacyFacet, Facet facet)
        {
            Assert.Equal(legacyFacet.Name, facet.Name);
            Assert.Equal(legacyFacet.FacetType.FullName, facet.FacetType.FullName);

            // Specialcase Variable, Max and Identity facet values - they are internal singleton objects.
            if (legacyFacet.Value != null
                && (new[] { "Max", "Variable", "Identity" }.Contains(legacyFacet.Value.ToString())
                    || facet.Name == "ConcurrencyMode"))
            {
                // this is to make sure we did not stick EF6 Max/Variable/Identity on legacy facet as the value
                Assert.Equal(typeof(LegacyMetadata.EdmType).Assembly, legacyFacet.Value.GetType().Assembly);

                Assert.NotNull(facet.Value);
                Assert.Equal(legacyFacet.Value.ToString(), facet.Value.ToString());
            }
            else
            {
                Assert.Equal(legacyFacet.Value, facet.Value);
            }

            Assert.Equal(legacyFacet.IsUnbounded, facet.IsUnbounded);
            Assert.Equal(LegacyMetadata.BuiltInTypeKind.Facet, legacyFacet.BuiltInTypeKind);
            Assert.Equal(BuiltInTypeKind.Facet, facet.BuiltInTypeKind);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:TypeUsageVerificationHelper.cs

示例3: VerifyTypeUsagesEquivalent

        public static void VerifyTypeUsagesEquivalent(LegacyMetadata.TypeUsage legacyTypeUsage, TypeUsage typeUsage)
        {
            if (typeUsage.EdmType.BuiltInTypeKind == BuiltInTypeKind.CollectionType)
            {
                VerifyTypeUsagesEquivalent(
                    ((LegacyMetadata.CollectionType)legacyTypeUsage.EdmType).TypeUsage,
                    ((CollectionType)typeUsage.EdmType).TypeUsage);
            }
            else
            {
                VerifyEdmTypesEquivalent(legacyTypeUsage.EdmType, typeUsage.EdmType);
            }

            var legacyTypeFacets = legacyTypeUsage.Facets.OrderBy(f => f.Name).ToArray();
            var typeFacets = typeUsage.Facets.OrderBy(f => f.Name).ToArray();

            Assert.Equal(legacyTypeFacets.Length, typeFacets.Length);
            for (var i = 0; i < legacyTypeFacets.Length; i++)
            {
                VerifyFacetsEquivalent(legacyTypeFacets[i], typeFacets[i]);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:22,代码来源:TypeUsageVerificationHelper.cs

示例4: 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;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:24,代码来源:ProviderCommandInfoUtils.cs

示例5: CreateTypeIdColumnMap

 /// <summary>
 /// Create a column map for the typeid column
 /// </summary>
 /// <param name="prop"></param>
 /// <returns></returns>
 private SimpleColumnMap CreateTypeIdColumnMap(md.EdmProperty prop)
 {
     return CreateSimpleColumnMap(md.Helper.GetModelTypeUsage(prop), c_TypeIdColumnName);
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:9,代码来源:ColumnMapProcessor.cs

示例6: FlattenComputedVar

        /// <summary>
        /// Helps flatten out a computedVar expression
        /// </summary>
        /// <param name="v">The Var</param>
        /// <param name="node">Subtree rooted at the VarDefOp expression</param>
        /// <param name="newNodes">list of new nodes produced</param>
        /// <param name="newType"></param>
        /// <returns>VarInfo for this var</returns>
        private void FlattenComputedVar(ComputedVar v, Node node, out List<Node> newNodes, out md.TypeUsage newType)
        {
            newNodes = new List<Node>();
            Node 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;
                Node newVarDefNode = m_command.CreateVarDefNode(definingExprNode, out newVar);
                newNodes.Add(newVarDefNode);
                m_varInfoMap.CreateCollectionVarInfo(v, newVar);
                return;
            }

            // Get the "new" type for the Var
            TypeInfo typeInfo = m_typeInfo.GetTypeInfo(v.Type);
            // Get a list of properties that we think are necessary 
            PropertyRefList desiredProperties = m_varPropertyMap[v];
            List<Var> newVars = new List<Var>();
            List<md.EdmProperty> newProps = new List<md.EdmProperty>();
            newNodes = new List<Node>();
            var hasNullSentinelVar = false;
            foreach (PropertyRef p in typeInfo.PropertyRefList)
            {
                // do I care for this property?
                if (!desiredProperties.Contains(p))
                {
                    continue;
                }

                md.EdmProperty 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;
                Node 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;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:80,代码来源:NominalTypeEliminator.cs

示例7: TryGetVar

 /// <summary>
 /// Get the Var corresponding to a specific property
 /// </summary>
 /// <param name="p">the requested property</param>
 /// <param name="v">the corresponding Var</param>
 /// <returns>true, if the Var was found</returns>
 internal bool TryGetVar(md.EdmProperty p, out Var v) {
     if (m_propertyToVarMap == null) {
         InitPropertyToVarMap();
     }
     return m_propertyToVarMap.TryGetValue(p, out v);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:12,代码来源:VarInfo.cs

示例8: BuildAccessorWithNulls

 /// <summary>
 /// A BuildAccessor variant. If the appropriate property was not found, then
 /// build up a null constant instead
 /// </summary>
 /// <param name="input"></param>
 /// <param name="property"></param>
 /// <returns></returns>
 private Node BuildAccessorWithNulls(Node input, md.EdmProperty property)
 {
     Node newNode = this.BuildAccessor(input, property);
     if (newNode == null)
     {
         newNode = CreateNullConstantNode(md.Helper.GetModelTypeUsage(property));
     }
     return newNode;
 }
开发者ID:uQr,项目名称:referencesource,代码行数:16,代码来源:NominalTypeEliminator.cs

示例9: CreateStructuredVarInfo

 /// <summary>
 /// Create a new VarInfo for a structured type Var
 /// </summary>
 /// <param name="v">The structured type Var</param>
 /// <param name="newType">"Mapped" type for v</param>
 /// <param name="newVars">List of vars corresponding to v</param>
 /// <param name="newProperties">Flattened Properties </param>
 /// <param name="newVarsIncludeNullSentinelVar">Do the new vars include a var that represents a null sentinel either for this type or for any nested type</param>
 /// <returns>the VarInfo</returns>
 internal VarInfo CreateStructuredVarInfo(Var v, md.RowType newType, List<Var> newVars, List<md.EdmProperty> newProperties, bool newVarsIncludeNullSentinelVar)
 {
     VarInfo varInfo = new StructuredVarInfo(newType, newVars, newProperties, newVarsIncludeNullSentinelVar);
     m_map.Add(v, varInfo);
     return varInfo;
 }
开发者ID:uQr,项目名称:referencesource,代码行数:15,代码来源:VarInfo.cs

示例10: GetPropertyValue

        /// <summary>
        /// Build up a key-value pair of (property, expression) to represent 
        /// the extraction of the appropriate property from the input expression
        /// </summary>
        /// <param name="input">The input (structured type) expression</param>
        /// <param name="property">The property in question</param>
        /// <param name="ignoreMissingProperties">should we ignore missing properties</param>
        /// <returns></returns>
        private KeyValuePair<md.EdmProperty, Node> GetPropertyValue(Node input, md.EdmProperty property, bool ignoreMissingProperties)
        {
            Node n = null;

            if (!ignoreMissingProperties)
            {
                n = BuildAccessorWithNulls(input, property);
            }
            else
            {
                n = BuildAccessor(input, property);
            }
            return new KeyValuePair<md.EdmProperty, Node>(property, n);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:NominalTypeEliminator.cs

示例11: 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)));
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:16,代码来源:TypeUtils.cs

示例12: 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);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:17,代码来源:ConstraintManager.cs

示例13: TypeInfo

 protected TypeInfo(md.TypeUsage type, TypeInfo superType)
 {
     m_type = type;
     m_immediateSubTypes = new List<TypeInfo>();
     m_superType = superType;
     if (superType != null)
     {
         // Add myself to my supertype's list of subtypes
         superType.m_immediateSubTypes.Add(this);
         // my supertype's root type is mine as well
         m_rootType = superType.RootType;
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:13,代码来源:TypeInfo.cs

示例14: 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;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:24,代码来源:TypeInfo.cs

示例15: LoadRelationships

        /// <summary>
        /// Load all relationships in this entity container
        /// </summary>
        /// <param name="entityContainer"></param>
        internal void LoadRelationships(md.EntityContainer entityContainer)
        {
            // Check to see if I've already loaded information for this entity container
            if (m_entityContainerMap.ContainsKey(entityContainer))
            {
                return;
            }

            // Load all relationships from this entitycontainer
            foreach (var e in entityContainer.BaseEntitySets)
            {
                var relationshipSet = e as md.RelationshipSet;
                if (relationshipSet == null)
                {
                    continue;
                }

                // Relationship sets can only contain relationships
                var relationshipType = relationshipSet.ElementType;
                var assocType = relationshipType as md.AssociationType;

                //
                // Handle only binary Association relationships for now
                //
                if (null == assocType
                    || !IsBinary(relationshipType))
                {
                    continue;
                }

                foreach (var constraint in assocType.ReferentialConstraints)
                {
                    List<ForeignKeyConstraint> fkConstraintList;
                    var fkConstraint = new ForeignKeyConstraint(relationshipSet, constraint);
                    if (!m_parentChildRelationships.TryGetValue(fkConstraint.Pair, out fkConstraintList))
                    {
                        fkConstraintList = new List<ForeignKeyConstraint>();
                        m_parentChildRelationships[fkConstraint.Pair] = fkConstraintList;
                    }
                    //
                    // Theoretically, we can have more than one fk constraint between
                    // the 2 tables (though, it is unlikely)
                    //
                    fkConstraintList.Add(fkConstraint);
                }
            }

            // Mark this entity container as already loaded
            m_entityContainerMap[entityContainer] = entityContainer;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:54,代码来源:ConstraintManager.cs


注:本文中的System.Data.Metadata.Edm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。