本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EdmItemCollection类的典型用法代码示例。如果您正苦于以下问题:C# EdmItemCollection类的具体用法?C# EdmItemCollection怎么用?C# EdmItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmItemCollection类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了EdmItemCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: DefaultObjectMappingItemCollection
// <summary>
// Constructor to create an instance of DefaultObjectMappingItemCollection.
// To start with we will create a Schema under which maps will be created.
// </summary>
public DefaultObjectMappingItemCollection(
EdmItemCollection edmCollection,
ObjectItemCollection objectCollection)
: base(DataSpace.OCSpace)
{
DebugCheck.NotNull(edmCollection);
DebugCheck.NotNull(objectCollection);
_edmCollection = edmCollection;
_objectCollection = objectCollection;
var cspaceTypes = _edmCollection.GetPrimitiveTypes();
foreach (var type in cspaceTypes)
{
var ospaceType = _objectCollection.GetMappedPrimitiveType(type.PrimitiveTypeKind);
Debug.Assert(ospaceType != null, "all primitive type must have been loaded");
AddInternalMapping(new ObjectTypeMapping(ospaceType, type), _clrTypeIndexes, _edmTypeIndexes);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:24,代码来源:DefaultObjectMappingItemCollection.cs
示例17: Can_initialize_from_edm_model_and_items_set_read_only_and_added_to_collection
public void Can_initialize_from_edm_model_and_items_set_read_only_and_added_to_collection()
{
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);
Assert.Equal(3.0, itemCollection.EdmVersion);
foreach (var globalItem in databaseMapping.Model.GlobalItems)
{
Assert.True(itemCollection.Contains(globalItem));
Assert.True(globalItem.IsReadOnly);
}
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:20,代码来源:EdmItemCollectionTests.cs
示例18: Visit
protected override void Visit(StorageEntityContainerMapping storageEntityContainerMapping)
{
Debug.Assert(storageEntityContainerMapping != null, "storageEntityContainerMapping cannot be null!");
// at the entry point of visitor, we setup the versions
Debug.Assert(
m_MappingVersion == storageEntityContainerMapping.StorageMappingItemCollection.MappingVersion,
"the original version and the mapping collection version are not the same");
m_MappingVersion = storageEntityContainerMapping.StorageMappingItemCollection.MappingVersion;
m_EdmItemCollection = storageEntityContainerMapping.StorageMappingItemCollection.EdmItemCollection;
int index;
if (!AddObjectToSeenListAndHashBuilder(storageEntityContainerMapping, out index))
{
// if this has been add to the seen list, then just
return;
}
if (m_itemsAlreadySeen.Count > 1)
{
// this means user try another visit over SECM, this is allowed but all the previous visit all lost due to clean
// user can visit different SECM objects by using the same visitor to load the SECM object
Clean();
Visit(storageEntityContainerMapping);
return;
}
AddObjectStartDumpToHashBuilder(storageEntityContainerMapping, index);
#region Inner data visit
AddObjectContentToHashBuilder(storageEntityContainerMapping.Identity);
AddV2ObjectContentToHashBuilder(storageEntityContainerMapping.GenerateUpdateViews, m_MappingVersion);
base.Visit(storageEntityContainerMapping);
#endregion
AddObjectEndDumpToHashBuilder();
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:41,代码来源:metadatamappinghashervisitor.cs
示例19: LoadTypes
public void LoadTypes(EdmItemCollection edmItemCollection, ObjectItemCollection objectItemCollection)
{
DebugCheck.NotNull(edmItemCollection);
DebugCheck.NotNull(objectItemCollection);
foreach (var cSpaceType in edmItemCollection.OfType<EdmType>().Where(
t => t.BuiltInTypeKind == BuiltInTypeKind.EntityType
|| t.BuiltInTypeKind == BuiltInTypeKind.EnumType
|| t.BuiltInTypeKind == BuiltInTypeKind.ComplexType))
{
var clrType = cSpaceType.GetClrType();
if (clrType != null)
{
var oSpaceType = _typeFactory.TryCreateType(clrType, cSpaceType);
if (oSpaceType != null)
{
Debug.Assert(!_typeFactory.CspaceToOspace.ContainsKey(cSpaceType));
_typeFactory.CspaceToOspace.Add(cSpaceType, oSpaceType);
}
}
else
{
Debug.Assert(!(cSpaceType is EntityType || cSpaceType is ComplexType || cSpaceType is EnumType));
}
}
_typeFactory.CreateRelationships(edmItemCollection);
foreach (var resolve in _typeFactory.ReferenceResolutions)
{
resolve();
}
foreach (var edmType in _typeFactory.LoadedTypes.Values)
{
edmType.SetReadOnly();
}
objectItemCollection.AddLoadedTypes(_typeFactory.LoadedTypes);
objectItemCollection.OSpaceTypesLoaded = true;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:41,代码来源:CodeFirstOSpaceLoader.cs
示例20: EdmItemCollection
public void GetItemCollection_on_both_C_and_S_space_using_item_collections_with_inconsistent_versions_throws_MetadataException()
{
var edmItemCollection = new EdmItemCollection(new[] { XDocument.Parse(_csdlV3).CreateReader() });
var storeItemCollection =
new StoreItemCollection(
new[]
{
XDocument.Parse(string.Format(CultureInfo.InvariantCulture, SsdlTemplate, XmlConstants.TargetNamespace_2))
.CreateReader()
});
var workspace = new MetadataWorkspace(
() => edmItemCollection,
() => storeItemCollection,
() => null);
workspace.GetItemCollection(DataSpace.CSpace); // this sets up the MetadataWorkspace's expected schema version as the csdl version i.e. 3.0
Assert.Equal(
Resources.Strings.DifferentSchemaVersionInCollection("StoreItemCollection", 2.0, 3.0),
Assert.Throws<MetadataException>(() => workspace.GetItemCollection(DataSpace.SSpace)).Message);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:21,代码来源:MetadataWorkspaceTests.cs
注:本文中的System.Data.Entity.Core.Metadata.Edm.EdmItemCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论