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


C# MetadataWorkspace.GetItems方法代码示例

本文整理汇总了C#中MetadataWorkspace.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataWorkspace.GetItems方法的具体用法?C# MetadataWorkspace.GetItems怎么用?C# MetadataWorkspace.GetItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MetadataWorkspace的用法示例。


在下文中一共展示了MetadataWorkspace.GetItems方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapperBase

        /// <summary>
        /// 
        /// </summary>
        /// <param name="metadataWorkspace"></param>
        /// <param name="entityContainer">Code first or DB first entityContainer</param>
        protected MapperBase(MetadataWorkspace metadataWorkspace, EntityContainer entityContainer)
        {
            MetadataWorkspace = metadataWorkspace;
            EntityContainer = entityContainer;

            var relations = MetadataWorkspace.GetItems(DataSpace.CSpace).OfType<AssociationType>();

            foreach (var associationType in relations)
            {
                foreach (var referentialConstraint in associationType.ReferentialConstraints)
                {
                    for (int i = 0; i < referentialConstraint.ToProperties.Count; ++i)
                    {
                        _fks[referentialConstraint.ToProperties[i]] = referentialConstraint.FromProperties[i];
                    }
                }
            }
        }
开发者ID:kjbartel,项目名称:efmappingapi,代码行数:23,代码来源:MapperBase.cs

示例2: FindEnumReferences

		// refs:
		// * http://romiller.com/2014/04/08/ef6-1-mapping-between-types-tables/
		// * http://blogs.msdn.com/b/appfabriccat/archive/2010/10/22/metadataworkspace-reference-in-wcf-services.aspx
		// * http://msdn.microsoft.com/en-us/library/system.data.metadata.edm.dataspace.aspx - describes meaning of OSpace etc
		// * http://stackoverflow.com/questions/22999330/mapping-from-iedmentity-to-clr

		internal IList<EnumReference> FindEnumReferences(MetadataWorkspace metadataWorkspace)
		{
			// Get the part of the model that contains info about the actual CLR types
			var objectItemCollection = ((ObjectItemCollection)metadataWorkspace.GetItemCollection(DataSpace.OSpace));
			// OSpace = Object Space

			var entities = metadataWorkspace.GetItems<EntityType>(DataSpace.OSpace);

			// find and return all the references to enum types
			var references = new List<EnumReference>();
			foreach (var entityType in entities)
			{
				var mappingFragment = FindSchemaMappingFragment(metadataWorkspace, entityType);

				// child types in TPH don't get mappings
				if (mappingFragment == null)
				{
					continue;
				}

				references.AddRange(ProcessEdmProperties(entityType.Properties, mappingFragment, objectItemCollection));
			}
			return references;
		}
开发者ID:sgebhardt,项目名称:ef-enum-to-lookup,代码行数:30,代码来源:MetadataHandler.cs

示例3: RelPropertyHelper

        internal RelPropertyHelper(MetadataWorkspace ws, HashSet<RelProperty> interestingRelProperties)
        {
            _relPropertyMap = new Dictionary<EntityTypeBase, List<RelProperty>>();
            _interestingRelProperties = interestingRelProperties;

            foreach (RelationshipType relationshipType in ws.GetItems<RelationshipType>(DataSpace.CSpace))
            {
                ProcessRelationship(relationshipType);
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:RelPropertyHelper.cs

示例4: GetClrType

 private static Type GetClrType(MetadataWorkspace metadata, ObjectItemCollection objectItemCollection, EntityTypeBase type)
 {
     return metadata
            .GetItems<EntityType>(DataSpace.OSpace)
            .Select(objectItemCollection.GetClrType)
            .Single(e => e.Name == type.Name);
 }
开发者ID:ArthurYiL,项目名称:EntityFramework.Utilities,代码行数:7,代码来源:MappingHelper.cs

示例5: FindStorageMapping

		private static EntitySetMapping FindStorageMapping(MetadataWorkspace metadata, EntitySet conceptualEntitySet)
		{
			// Find the mapping between conceptual and storage model for this entity set
			var entityContainerMappings = metadata.GetItems<EntityContainerMapping>(DataSpace.CSSpace);
			// CSSpace = Conceptual model to Storage model mappings
			if (entityContainerMappings.Count() != 1)
			{
				throw new EnumGeneratorException(string.Format("{0} EntityContainerMappings found.", entityContainerMappings.Count()));
			}
			var containerMapping = entityContainerMappings.Single();
			var mappings = containerMapping.EntitySetMappings.Where(s => s.EntitySet == conceptualEntitySet).ToList();
			if (mappings.Count() != 1)
			{
				throw new EnumGeneratorException(string.Format(
					"{0} EntitySetMappings found for entitySet '{1}'.", mappings.Count(), conceptualEntitySet.Name));
			}
			var mapping = mappings.Single();
			return mapping;
		}
开发者ID:sgebhardt,项目名称:ef-enum-to-lookup,代码行数:19,代码来源:MetadataHandler.cs

示例6: FindObjectSpaceEntityMetadata

		private static EntityType FindObjectSpaceEntityMetadata(MetadataWorkspace metadata, EntityType entityType)
		{
			// Get the entity type from the model that maps to the CLR type
			var entityTypes = metadata
				.GetItems<EntityType>(DataSpace.OSpace) // OSpace = Object Space
				.Where(e => e == entityType)
				.ToList();
			if (entityTypes.Count() != 1)
			{
				throw new EnumGeneratorException(string.Format("{0} entities of type {1} found in mapping.", entityTypes.Count(),
					entityType));
			}
			var entityMetadata = entityTypes.Single();
			return entityMetadata;
		}
开发者ID:sgebhardt,项目名称:ef-enum-to-lookup,代码行数:15,代码来源:MetadataHandler.cs

示例7: FindConceptualEntity

		private static EntitySet FindConceptualEntity(MetadataWorkspace metadata, EntityType entityType)
		{
			var entityMetadata = FindObjectSpaceEntityMetadata(metadata, entityType);

			// Get the entity set that uses this entity type
			var containers = metadata
				.GetItems<EntityContainer>(DataSpace.CSpace); // CSpace = Conceptual model
			if (containers.Count() != 1)
			{
				throw new EnumGeneratorException(string.Format("{0} EntityContainer's found.", containers.Count()));
			}
			var container = containers.Single();

			var entitySets = container
				.EntitySets
				.Where(s => s.ElementType.Name == entityMetadata.Name)
				// doesn't seem to be possible to get at the Object-Conceptual mappings from the public API so match on name.
				.ToList();

			// Child types in Table-per-Hierarchy don't have any mappings defined as they don't add any new tables, so skip them.
			if (!entitySets.Any())
			{
				return null;
			}

			if (entitySets.Count() != 1)
			{
				throw new EnumGeneratorException(string.Format(
					"{0} EntitySet's found for element type '{1}'.", entitySets.Count(), entityMetadata.Name));
			}
			var entitySet = entitySets.Single();

			return entitySet;
		}
开发者ID:sgebhardt,项目名称:ef-enum-to-lookup,代码行数:34,代码来源:MetadataHandler.cs

示例8: ForceViewGeneration

 private static void ForceViewGeneration(MetadataWorkspace workspace)
 {
     ReadOnlyCollection<EntityContainer> containers = workspace.GetItems<EntityContainer>(DataSpace.SSpace);
     Debug.Assert(containers.Count != 0, "no s space containers found");
     Debug.Assert(containers[0].BaseEntitySets.Count != 0, "no entity sets in the sspace container");
     workspace.GetCqtView(containers[0].BaseEntitySets[0]);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:EntityStoreSchemaGenerator.cs

示例9: GetEntitySetsWithAssociationSets

 /// <summary>
 /// Gets all entity sets that participate as members for the specified <paramref name="associationType"/>.
 /// </summary>
 /// <param name="workspace">Workspace with metadata.</param>
 /// <param name="associationType">Type of assocation to check.</param>
 /// <param name="member">Member of association to check.</param>
 /// <returns>
 /// All <see cref="EntitySet"/> instances that are are on the <paramref name="member"/> role for 
 /// some association of <paramref name="associationType"/>.
 /// </returns>
 private static IEnumerable<EntitySet> GetEntitySetsWithAssociationSets(
     MetadataWorkspace workspace,
     RelationshipType associationType,
     RelationshipEndMember member)
 {
     Debug.Assert(workspace != null, "workspace != null");
     Debug.Assert(associationType != null, "associationType != null");
     Debug.Assert(member != null, "member != null");
     foreach (EntityContainer container in workspace.GetItems<EntityContainer>(DataSpace.CSpace))
     {
         foreach (AssociationSet associationSet in container.BaseEntitySets.OfType<AssociationSet>())
         {
             if (associationSet.ElementType == associationType)
             {
                 foreach (AssociationSetEnd end in associationSet.AssociationSetEnds)
                 {
                     if (end.CorrespondingAssociationEndMember == member)
                     {
                         yield return end.EntitySet;
                     }
                 }
             }
         }
     }
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:35,代码来源:ObjectContextServiceProvider.cs

示例10: GetEntitySetsForType

 /// <summary>
 /// Gets all <see cref="EntitySet"/> instance that may hold an entity of type <paramref name="type"/>.
 /// </summary>
 /// <param name="workspace">Workspace with metadata.</param>
 /// <param name="type">Entity type to get entity sets for.</param>
 /// <returns>An enumeration of <see cref="EntitySet"/> instances that can hold <paramref name="type"/>.</returns>
 private static IEnumerable<EntitySet> GetEntitySetsForType(MetadataWorkspace workspace, EntityType type)
 {
     Debug.Assert(type != null, "type != null");
     Debug.Assert(workspace != null, "workspace != null");
     foreach (EntityContainer container in workspace.GetItems<EntityContainer>(DataSpace.CSpace))
     {
         foreach (EntitySet entitySet in container.BaseEntitySets.OfType<EntitySet>())
         {
             if (IsAssignableFrom(entitySet.ElementType, type))
             {
                 yield return entitySet;
             }
         }
     }
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:21,代码来源:ObjectContextServiceProvider.cs


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