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


C# Edm.EdmItemCollection类代码示例

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


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

示例1: GetStorageMappingItemCollection

        public static StorageMappingItemCollection GetStorageMappingItemCollection(
            this XDocument model, out DbProviderInfo providerInfo)
        {
            DebugCheck.NotNull(model);

            var edmItemCollection
                = new EdmItemCollection(
                    new[]
                        {
                            model.Descendants(EdmXNames.Csdl.SchemaNames).Single().CreateReader()
                        });

            var ssdlSchemaElement = model.Descendants(EdmXNames.Ssdl.SchemaNames).Single();

            providerInfo = new DbProviderInfo(
                ssdlSchemaElement.ProviderAttribute(),
                ssdlSchemaElement.ProviderManifestTokenAttribute());

            var storeItemCollection
                = new StoreItemCollection(
                    new[]
                        {
                            ssdlSchemaElement.CreateReader()
                        });

            return new StorageMappingItemCollection(
                edmItemCollection,
                storeItemCollection,
                new[] { new XElement(model.Descendants(EdmXNames.Msl.MappingNames).Single()).CreateReader() });
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:30,代码来源:XDocumentExtensions.cs

示例2: Code_first_built_complex_types_matches_som_loaded_complex_types

        public void Code_first_built_complex_types_matches_som_loaded_complex_types()
        {
            var context = new ShopContext_v1();
            var compiledModel = context.InternalContext.CodeFirstModel;

            var builder = compiledModel.CachedModelBuilder.Clone();

            var databaseMapping
                = builder.Build(ProviderRegistry.Sql2008_ProviderInfo).DatabaseMapping;

            var itemCollection = new EdmItemCollection(databaseMapping.Model);

            var complexTypes = databaseMapping.Model.ComplexTypes.ToList();
            var somComplexTypes = itemCollection.GetItems<ComplexType>();

            Assert.Equal(complexTypes.Count(), somComplexTypes.Count());

            foreach (var complexType in complexTypes)
            {
                var somComplexType = somComplexTypes.Single(e => e.Name == complexType.Name);

                Assert.Equal(complexType.NamespaceName, somComplexType.NamespaceName);
                Assert.Equal(complexType.Identity, somComplexType.Identity);
                Assert.Equal(complexType.Abstract, somComplexType.Abstract);
                Assert.Equal(complexType.FullName, somComplexType.FullName);
                Assert.Equal(complexType.Members.Count, somComplexType.Members.Count);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:28,代码来源:EdmItemCollectionTests.cs

示例3: LoadAssembly

        internal static void LoadAssembly(
            Assembly assembly, bool loadReferencedAssemblies,
            KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action<String> logLoadMessage, ref object loaderCookie,
            out Dictionary<string, EdmType> typesInLoading, out List<EdmItemError> errors)
        {
            Debug.Assert(
                loaderCookie == null || loaderCookie is Func<Assembly, ObjectItemLoadingSessionData, ObjectItemAssemblyLoader>,
                "This is a bad loader cookie");
            typesInLoading = null;
            errors = null;

            using (var lockedAssemblyCache = AquireLockedAssemblyCache())
            {
                var loadingData = new ObjectItemLoadingSessionData(
                    knownAssemblies, lockedAssemblyCache, edmItemCollection, logLoadMessage, loaderCookie);

                LoadAssembly(assembly, loadReferencedAssemblies, loadingData);
                loaderCookie = loadingData.LoaderCookie;
                // resolve references to top level types (base types, navigation properties returns and associations, and complex type properties)
                loadingData.CompleteSession();

                if (loadingData.EdmItemErrors.Count == 0)
                {
                    // do the validation for the all the new types
                    // Now, perform validation on all the new types
                    var validator = new EdmValidator();
                    validator.SkipReadOnlyItems = true;
                    validator.Validate(loadingData.TypesInLoading.Values, loadingData.EdmItemErrors);
                    // Update the global cache if there are no errors
                    if (loadingData.EdmItemErrors.Count == 0)
                    {
                        if (ObjectItemAssemblyLoader.IsAttributeLoader(loadingData.ObjectItemAssemblyLoaderFactory))
                        {
                            // we only cache items from the attribute loader globally, the 
                            // items loaded by convention will change depending on the cspace 
                            // provided.  cspace will have a cache of it's own for assemblies
                            UpdateCache(lockedAssemblyCache, loadingData.AssembliesLoaded);
                        }
                        else if (loadingData.EdmItemCollection != null
                                 &&
                                 ObjectItemAssemblyLoader.IsConventionLoader(loadingData.ObjectItemAssemblyLoaderFactory))
                        {
                            UpdateCache(loadingData.EdmItemCollection, loadingData.AssembliesLoaded);
                        }
                    }
                }

                if (loadingData.TypesInLoading.Count > 0)
                {
                    foreach (var edmType in loadingData.TypesInLoading.Values)
                    {
                        edmType.SetReadOnly();
                    }
                }

                // Update the out parameters once you are done with loading
                typesInLoading = loadingData.TypesInLoading;
                errors = loadingData.EdmItemErrors;
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:60,代码来源:AssemblyCache.cs

示例4: CompileFunctionDefinition

        // <summary>
        // Compiles eSQL <paramref name="functionDefinition" /> and returns <see cref="DbLambda" />.
        // Guarantees type match of lambda variables and <paramref name="functionParameters" />.
        // Passes thru all excepions coming from <see cref="CqlQuery" />.
        // </summary>
        internal static DbLambda CompileFunctionDefinition(
            string functionDefinition,
            IList<FunctionParameter> functionParameters,
            EdmItemCollection edmItemCollection)
        {
            DebugCheck.NotNull(functionParameters);
            DebugCheck.NotNull(edmItemCollection);

            var perspective = new ModelPerspective(
                new MetadataWorkspace(
                    () => edmItemCollection,
                    () => null,
                    () => null));

            // Since we compile lambda expression and generate variables from the function parameter definitions,
            // the returned DbLambda will contain variable types that match function parameter types.
            var functionBody = CqlQuery.CompileQueryCommandLambda(
                functionDefinition,
                perspective,
                null /* use default parser options */,
                null /* parameters */,
                functionParameters.Select(pInfo => pInfo.TypeUsage.Variable(pInfo.Name)));
            Debug.Assert(functionBody != null, "functionBody != null");

            return functionBody;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:31,代码来源:ExternalCalls.cs

示例5: Create

 /// <summary>
 ///     Recursively generates <see cref="MemberPath" />s for the members of the types stored in the <paramref name="extent" />.
 /// </summary>
 internal static MemberProjectionIndex Create(EntitySetBase extent, EdmItemCollection edmItemCollection)
 {
     // We generate the indices for the projected slots as we traverse the metadata.
     var index = new MemberProjectionIndex();
     GatherPartialSignature(index, edmItemCollection, new MemberPath(extent), false); // need not only keys
     return index;
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:10,代码来源:MemberProjectionIndex.cs

示例6: Prepare_returns_a_new_instance

        public void Prepare_returns_a_new_instance()
        {
            var objectQueryExecutionPlanFactory = new ObjectQueryExecutionPlanFactory(
                Common.Internal.Materialization.MockHelper.CreateTranslator<object>());

            var metadataWorkspace = new MetadataWorkspace();
            var edmItemCollection = new EdmItemCollection();
            metadataWorkspace.RegisterItemCollection(edmItemCollection);
            metadataWorkspace.RegisterItemCollection(new ObjectItemCollection());
            var fakeSqlProviderManifest = new FakeSqlProviderServices().GetProviderManifest("2008");
            var storeItemCollection = new StoreItemCollection(FakeSqlProviderFactory.Instance, fakeSqlProviderManifest, "2008");
            metadataWorkspace.RegisterItemCollection(storeItemCollection);
            metadataWorkspace.RegisterItemCollection(new StorageMappingItemCollection(edmItemCollection, storeItemCollection, Enumerable.Empty<XmlReader>()));

            var fakeSqlConnection = new FakeSqlConnection();
            fakeSqlConnection.ConnectionString = "foo";
            var entityConnection = new EntityConnection(metadataWorkspace, fakeSqlConnection, false);

            var objectContext = new ObjectContext(entityConnection);
            var dbExpression = new DbNullExpression(TypeUsage.Create(fakeSqlProviderManifest.GetStoreTypes().First()));
            var dbQueryCommandTree = new DbQueryCommandTree(metadataWorkspace, DataSpace.CSpace,
               dbExpression, validate: false);
            var parameters = new List<Tuple<ObjectParameter, QueryParameterExpression>>();

            var objectQueryExecutionPlan = objectQueryExecutionPlanFactory.Prepare(objectContext, dbQueryCommandTree, typeof(object),
                MergeOption.NoTracking, new Span(), parameters, aliasGenerator: null);

            Assert.NotNull(objectQueryExecutionPlan);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:29,代码来源:ObjectQueryExecutionPlanFactoryTests.cs

示例7: CreateMetadataWorkspaceFromResources

        /// <summary>
        /// Creates the MetadataWorkspace for the given context type and base context type.
        /// </summary>
        /// <param name="contextType">The type of the context.</param>
        /// <param name="baseContextType">The base context type (DbContext or ObjectContext).</param>
        /// <returns>The generated <see cref="System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace"/></returns>
        public static MetadataWorkspace CreateMetadataWorkspaceFromResources(Type contextType, Type baseContextType)
        {
            // get the set of embedded mapping resources for the target assembly and create
            // a metadata workspace info for each group
            var metadataResourcePaths = FindMetadataResources(contextType.Assembly);
            var workspaceInfos = GetMetadataWorkspaceInfos(metadataResourcePaths);

            // Search for the correct EntityContainer by name and if found, create
            // a comlete MetadataWorkspace and return it
            foreach (var workspaceInfo in workspaceInfos) {
                var edmItemCollection = new EdmItemCollection(workspaceInfo.Csdl);

                var currentType = contextType;
                while (currentType != baseContextType && currentType != typeof (object)) {
                    EntityContainer container;
                    if (edmItemCollection.TryGetEntityContainer(currentType.Name, out container)) {
                        var store = new StoreItemCollection(workspaceInfo.Ssdl);
                        var mapping = new StorageMappingItemCollection(edmItemCollection, store, workspaceInfo.Msl);
                        var workspace = new MetadataWorkspace();
                        workspace.RegisterItemCollection(edmItemCollection);
                        workspace.RegisterItemCollection(store);
                        workspace.RegisterItemCollection(mapping);
                        workspace.RegisterItemCollection(new ObjectItemCollection());
                        return workspace;
                    }

                    currentType = currentType.BaseType;
                }
            }
            return null;
        }
开发者ID:Rhombulus,项目名称:aftermath,代码行数:37,代码来源:MetadataWorkspaceUtilities.cs

示例8: MemberDomainMap

 private MemberDomainMap(
     Dictionary<MemberPath, CellConstantSet> domainMap,
     Dictionary<MemberPath, CellConstantSet> nonConditionDomainMap, EdmItemCollection edmItemCollection)
 {
     m_conditionDomainMap = domainMap;
     m_nonConditionDomainMap = nonConditionDomainMap;
     m_edmItemCollection = edmItemCollection;
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:MemberDomainMap.cs

示例9: HaveSeenInCompatibleContext

 public bool HaveSeenInCompatibleContext(object loaderCookie, EdmItemCollection itemCollection)
 {
     // a new "context" is only when we have not seen this assembly with an itemCollection that is non-null
     // and we now have a non-null itemCollection, and we are not already in AttributeLoader mode.
     return SeenWithEdmItemCollection ||
            itemCollection == null ||
            ObjectItemAssemblyLoader.IsAttributeLoader(loaderCookie);
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:KnownAssemblyEntry.cs

示例10: StorageMappingItemCollection_Create_factory_method_throws_for_null_storeItemCollection

        public void StorageMappingItemCollection_Create_factory_method_throws_for_null_storeItemCollection()
        {
            var edmItemCollection = new EdmItemCollection(new[] { XDocument.Parse(Csdl).CreateReader() });

            IList<EdmSchemaError> errors;

            Assert.Equal("storeItemCollection",
                Assert.Throws<ArgumentNullException>(
                    () => StorageMappingItemCollection.Create(edmItemCollection, null, null, null, out errors)).ParamName);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:10,代码来源:StorageMappingItemCollectionTests.cs

示例11: DefaultObjectMappingItemCollection

 /// <summary>
 /// Constrcutor to create an instance of DefaultObjectMappingItemCollection.
 /// To start with we will create a Schema under which maps will be created.
 /// </summary>
 /// <param name="edmCollection"></param>
 /// <param name="objectCollection"></param>
 public DefaultObjectMappingItemCollection(
     EdmItemCollection edmCollection,
     ObjectItemCollection objectCollection)
     : base(DataSpace.OCSpace)
 {
     Contract.Requires(edmCollection != null);
     Contract.Requires(objectCollection != null);
     m_edmCollection = edmCollection;
     m_objectCollection = objectCollection;
     LoadPrimitiveMaps();
 }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:17,代码来源:DefaultObjectMappingItemCollection.cs

示例12: CompileFunctionDefinition_uses_the_given_item_collection

        public void CompileFunctionDefinition_uses_the_given_item_collection()
        {
            var edmItemCollection = new EdmItemCollection(new[] { XDocument.Parse(ProductModel.CsdlWithFunctions).CreateReader() });

            Assert.Equal(
                "ProductModel.F_NoBody()",
                ((DbFunctionExpression)ExternalCalls.CompileFunctionDefinition(
                    "ProductModel.F_NoBody()",
                    new List<FunctionParameter>(),
                    edmItemCollection).Body).Function.Identity);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:ExternalCallsTests.cs

示例13: DefaultObjectMappingItemCollection

        /// <summary>
        ///     Constructor to create an instance of DefaultObjectMappingItemCollection.
        ///     To start with we will create a Schema under which maps will be created.
        /// </summary>
        /// <param name="edmCollection"> </param>
        /// <param name="objectCollection"> </param>
        public DefaultObjectMappingItemCollection(
            EdmItemCollection edmCollection,
            ObjectItemCollection objectCollection)
            : base(DataSpace.OCSpace)
        {
            DebugCheck.NotNull(edmCollection);
            DebugCheck.NotNull(objectCollection);

            m_edmCollection = edmCollection;
            m_objectCollection = objectCollection;
            LoadPrimitiveMaps();
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:18,代码来源:DefaultObjectMappingItemCollection.cs

示例14: TryGetKnownAssembly

        internal bool TryGetKnownAssembly(
            Assembly assembly, object loaderCookie, EdmItemCollection itemCollection, out KnownAssemblyEntry entry)
        {
            if (!_assemblies.TryGetValue(assembly, out entry))
            {
                return false;
            }

            if (!entry.HaveSeenInCompatibleContext(loaderCookie, itemCollection))
            {
                return false;
            }

            return true;
        }
开发者ID:junxy,项目名称:entityframework,代码行数:15,代码来源:KnownAssembliesSet.cs

示例15: ToMetadataWorkspace

        public static MetadataWorkspace ToMetadataWorkspace(this DbDatabaseMapping databaseMapping)
        {
            DebugCheck.NotNull(databaseMapping);

            var itemCollection = new EdmItemCollection(databaseMapping.Model);
            var storeItemCollection = new StoreItemCollection(databaseMapping.Database);
            var storageMappingItemCollection = databaseMapping.ToStorageMappingItemCollection(itemCollection, storeItemCollection);

            var workspace = new MetadataWorkspace(
                () => itemCollection,
                () => storeItemCollection,
                () => storageMappingItemCollection);

            new CodeFirstOSpaceLoader().LoadTypes(itemCollection, (ObjectItemCollection)workspace.GetItemCollection(DataSpace.OSpace));

            return workspace;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:17,代码来源:DbDatabaseMappingExtensions.cs


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