本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EdmProperty类的典型用法代码示例。如果您正苦于以下问题:C# EdmProperty类的具体用法?C# EdmProperty怎么用?C# EdmProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmProperty类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了EdmProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IncludeColumn
public static EdmProperty IncludeColumn(
EntityType table, EdmProperty templateColumn, Func<EdmProperty, bool> isCompatible, bool useExisting)
{
DebugCheck.NotNull(table);
DebugCheck.NotNull(templateColumn);
var existingColumn = table.Properties.FirstOrDefault(isCompatible);
if (existingColumn == null)
{
templateColumn = templateColumn.Clone();
}
else if (!useExisting
&& !existingColumn.IsPrimaryKeyColumn)
{
templateColumn = templateColumn.Clone();
}
else
{
templateColumn = existingColumn;
}
AddColumn(table, templateColumn);
return templateColumn;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:EntityMappingTransformer.cs
示例2: Discover
public override IConfiguration Discover(EdmProperty property, DbModel model)
{
Debug.Assert(property != null, "property is null.");
Debug.Assert(model != null, "model is null.");
if (!_lengthTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
{
// Doesn't apply
return null;
}
if (property.IsMaxLength
|| !property.MaxLength.HasValue
|| (property.MaxLength.Value == 128 && property.IsKey()))
{
// By convention
return null;
}
var configuration = property.PrimitiveType.PrimitiveTypeKind == PrimitiveTypeKind.String
? new MaxLengthStringConfiguration()
: new MaxLengthConfiguration();
configuration.MaxLength = property.MaxLength.Value;
return configuration;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:MaxLengthDiscoverer.cs
示例3: MapTableColumn
protected EdmProperty MapTableColumn(
EdmProperty property,
string columnName,
bool isInstancePropertyOnDerivedType)
{
DebugCheck.NotNull(property);
DebugCheck.NotEmpty(columnName);
var underlyingTypeUsage
= TypeUsage.Create(property.UnderlyingPrimitiveType, property.TypeUsage.Facets);
var storeTypeUsage = _providerManifest.GetStoreType(underlyingTypeUsage);
var tableColumnMetadata
= new EdmProperty(columnName, storeTypeUsage)
{
Nullable = isInstancePropertyOnDerivedType || property.Nullable
};
if (tableColumnMetadata.IsPrimaryKeyColumn)
{
tableColumnMetadata.Nullable = false;
}
var storeGeneratedPattern = property.GetStoreGeneratedPattern();
if (storeGeneratedPattern != null)
{
tableColumnMetadata.StoreGeneratedPattern = storeGeneratedPattern.Value;
}
MapPrimitivePropertyFacets(property, tableColumnMetadata, storeTypeUsage);
return tableColumnMetadata;
}
开发者ID:jwanagel,项目名称:jjwtest,代码行数:35,代码来源:StructuralTypeMappingGenerator.cs
示例4: FunctionImportMappingComposable
internal FunctionImportMappingComposable(
EdmFunction functionImport,
EdmFunction targetFunction,
List<Tuple<StructuralType, List<StorageConditionPropertyMapping>, List<StoragePropertyMapping>>> structuralTypeMappings,
EdmProperty[] targetFunctionKeys,
StorageMappingItemCollection mappingItemCollection)
: base(functionImport, targetFunction)
{
DebugCheck.NotNull(mappingItemCollection);
Debug.Assert(functionImport.IsComposableAttribute, "functionImport.IsComposableAttribute");
Debug.Assert(targetFunction.IsComposableAttribute, "targetFunction.IsComposableAttribute");
Debug.Assert(
functionImport.EntitySet == null || structuralTypeMappings != null,
"Function import returning entities must have structuralTypeMappings.");
Debug.Assert(
structuralTypeMappings == null || structuralTypeMappings.Count > 0, "Non-null structuralTypeMappings must not be empty.");
EdmType resultType;
Debug.Assert(
structuralTypeMappings != null ||
MetadataHelper.TryGetFunctionImportReturnType(functionImport, 0, out resultType) && TypeSemantics.IsScalarType(resultType),
"Either type mappings should be specified or the function import should be Collection(Scalar).");
Debug.Assert(
functionImport.EntitySet == null || targetFunctionKeys != null,
"Keys must be inferred for a function import returning entities.");
Debug.Assert(targetFunctionKeys == null || targetFunctionKeys.Length > 0, "Keys must be null or non-empty.");
m_mappingItemCollection = mappingItemCollection;
// We will use these parameters to target s-space function calls in the generated command tree.
// Since enums don't exist in s-space we need to use the underlying type.
m_commandParameters =
functionImport.Parameters.Select(p => TypeHelpers.GetPrimitiveTypeUsageForScalar(p.TypeUsage).Parameter(p.Name)).ToArray();
m_structuralTypeMappings = structuralTypeMappings;
m_targetFunctionKeys = targetFunctionKeys;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:34,代码来源:FunctionImportMappingComposable.cs
示例5: IncludeColumn
public static EdmProperty IncludeColumn(
EntityType table, EdmProperty templateColumn, bool useExisting)
{
DebugCheck.NotNull(table);
DebugCheck.NotNull(templateColumn);
var existingColumn =
table.Properties.SingleOrDefault(c => string.Equals(c.Name, templateColumn.Name, StringComparison.Ordinal));
if (existingColumn == null)
{
templateColumn = templateColumn.Clone();
}
else if (!useExisting
&& !existingColumn.IsPrimaryKeyColumn)
{
templateColumn = templateColumn.Clone();
}
else
{
templateColumn = existingColumn;
}
AddColumn(table, templateColumn);
return templateColumn;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:27,代码来源:EntityMappingTransformer.cs
示例6: Configure_should_rename_columns_when_right_keys_configured
public void Configure_should_rename_columns_when_right_keys_configured()
{
var database = new EdmModel(DataSpace.CSpace);
var associationSetMapping
= new StorageAssociationSetMapping(
new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)),
new EntitySet())
.Initialize();
var column = new EdmProperty("C");
associationSetMapping.TargetEndMapping.AddProperty(new StorageScalarPropertyMapping(new EdmProperty("PK"), column));
var manyToManyAssociationMappingConfiguration
= new ManyToManyAssociationMappingConfiguration();
manyToManyAssociationMappingConfiguration.MapRightKey("NewName");
var mockPropertyInfo = new MockPropertyInfo();
associationSetMapping.SourceEndMapping.EndMember = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
associationSetMapping.SourceEndMapping.EndMember.SetClrPropertyInfo(mockPropertyInfo);
manyToManyAssociationMappingConfiguration.Configure(associationSetMapping, database, mockPropertyInfo);
Assert.Equal("NewName", column.Name);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:28,代码来源:ManyToManyAssociationMappingConfigurationTests.cs
示例7: Can_generate_scalar_and_complex_properties_when_update
public void Can_generate_scalar_and_complex_properties_when_update()
{
var functionParameterMappingGenerator
= new FunctionParameterMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest);
var property0 = new EdmProperty("P0");
var property1 = new EdmProperty("P1");
var property2 = new EdmProperty("P2");
property2.SetStoreGeneratedPattern(StoreGeneratedPattern.Computed);
property2.ConcurrencyMode = ConcurrencyMode.Fixed;
var complexType = new ComplexType("CT", "N", DataSpace.CSpace);
complexType.AddMember(property1);
var complexProperty = EdmProperty.CreateComplex("C", complexType);
var parameterBindings
= functionParameterMappingGenerator
.Generate(
ModificationOperator.Update,
new[] { property0, complexProperty, property2 },
new[]
{
new ColumnMappingBuilder(new EdmProperty("C0"), new[] { property0 }),
new ColumnMappingBuilder(new EdmProperty("C_P1"), new[] { complexProperty, property1 }),
new ColumnMappingBuilder(new EdmProperty("C2"), new[] { property2 })
},
new List<EdmProperty>(),
useOriginalValues: true)
.ToList();
Assert.Equal(3, parameterBindings.Count());
var parameterBinding = parameterBindings.First();
Assert.Equal("C0", parameterBinding.Parameter.Name);
Assert.Same(property0, parameterBinding.MemberPath.Members.Single());
Assert.Equal("String", parameterBinding.Parameter.TypeName);
Assert.Equal(ParameterMode.In, parameterBinding.Parameter.Mode);
Assert.False(parameterBinding.IsCurrent);
parameterBinding = parameterBindings.ElementAt(1);
Assert.Equal("C_P1", parameterBinding.Parameter.Name);
Assert.Same(complexProperty, parameterBinding.MemberPath.Members.First());
Assert.Same(property1, parameterBinding.MemberPath.Members.Last());
Assert.Equal("String", parameterBinding.Parameter.TypeName);
Assert.Equal(ParameterMode.In, parameterBinding.Parameter.Mode);
Assert.False(parameterBinding.IsCurrent);
parameterBinding = parameterBindings.Last();
Assert.Equal("C2_Original", parameterBinding.Parameter.Name);
Assert.Same(property2, parameterBinding.MemberPath.Members.Single());
Assert.Equal("String", parameterBinding.Parameter.TypeName);
Assert.Equal(ParameterMode.In, parameterBinding.Parameter.Mode);
Assert.False(parameterBinding.IsCurrent);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:60,代码来源:FunctionParameterMappingGeneratorTests.cs
示例8: Can_get_flattened_properties_for_nested_mapping
public void Can_get_flattened_properties_for_nested_mapping()
{
var mappingFragment
= new MappingFragment(
new EntitySet(),
new EntityTypeMapping(
new EntitySetMapping(
new EntitySet(),
new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);
Assert.Empty(mappingFragment.ColumnMappings);
var columnProperty = new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace }));
var property1 = EdmProperty.CreateComplex("P1", new ComplexType("CT"));
var property2 = new EdmProperty("P2");
var columnMappingBuilder1 = new ColumnMappingBuilder(columnProperty, new[] { property1, property2 });
mappingFragment.AddColumnMapping(columnMappingBuilder1);
var columnMappingBuilder2 = new ColumnMappingBuilder(columnProperty, new[] { property2 });
mappingFragment.AddColumnMapping(columnMappingBuilder2);
var columnMappingBuilders = mappingFragment.FlattenedProperties.ToList();
Assert.Equal(2, columnMappingBuilders.Count());
Assert.True(columnMappingBuilder1.PropertyPath.SequenceEqual(columnMappingBuilders.First().PropertyPath));
Assert.True(columnMappingBuilder2.PropertyPath.SequenceEqual(columnMappingBuilders.Last().PropertyPath));
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:30,代码来源:MappingFragmentTests.cs
示例9: MapPrimitivePropertyFacets
internal static void MapPrimitivePropertyFacets(
EdmProperty property, EdmProperty column, TypeUsage typeUsage)
{
DebugCheck.NotNull(property);
DebugCheck.NotNull(column);
DebugCheck.NotNull(typeUsage);
if (IsValidFacet(typeUsage, XmlConstants.FixedLengthElement))
{
column.IsFixedLength = property.IsFixedLength;
}
if (IsValidFacet(typeUsage, XmlConstants.MaxLengthElement))
{
column.IsMaxLength = property.IsMaxLength;
column.MaxLength = property.MaxLength;
}
if (IsValidFacet(typeUsage, XmlConstants.UnicodeElement))
{
column.IsUnicode = property.IsUnicode;
}
if (IsValidFacet(typeUsage, XmlConstants.PrecisionElement))
{
column.Precision = property.Precision;
}
if (IsValidFacet(typeUsage, XmlConstants.ScaleElement))
{
column.Scale = property.Scale;
}
}
开发者ID:jwanagel,项目名称:jjwtest,代码行数:33,代码来源:StructuralTypeMappingGenerator.cs
示例10: Discover
public IConfiguration Discover(EdmProperty property, DbModel model)
{
Debug.Assert(property != null, "property is null.");
Debug.Assert(model != null, "model is null.");
var columnProperty = model.GetColumn(property);
if (property.IsKey() && _identityKeyTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
{
if (columnProperty.IsStoreGeneratedIdentity)
{
// By convention
return null;
}
}
else if (columnProperty.IsTimestamp())
{
// By convention
return null;
}
else if (columnProperty.StoreGeneratedPattern == StoreGeneratedPattern.None)
{
// Doesn't apply
return null;
}
return new DatabaseGeneratedConfiguration { StoreGeneratedPattern = columnProperty.StoreGeneratedPattern };
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:28,代码来源:DatabaseGeneratedDiscoverer.cs
示例11: EdmModel_NameIsTooLong_not_triggered_for_row_and_collection_types
public void EdmModel_NameIsTooLong_not_triggered_for_row_and_collection_types()
{
var intType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32);
var properties = new EdmProperty[100];
for (int i = 0; i < 100; i++)
{
properties[i] = EdmProperty.Primitive("Property" + i, intType);
}
var rowType = new RowType(properties);
foreach (var type in new EdmType[] { rowType, rowType.GetCollectionType() })
{
var validationContext
= new EdmModelValidationContext(new EdmModel(DataSpace.SSpace), true);
DataModelErrorEventArgs errorEventArgs = null;
validationContext.OnError += (_, e) => errorEventArgs = e;
EdmModelSyntacticValidationRules
.EdmModel_NameIsTooLong
.Evaluate(validationContext, type);
Assert.Null(errorEventArgs);
}
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:26,代码来源:EdmModelSyntacticValidationRulesTests.cs
示例12: Discover
public IConfiguration Discover(EdmProperty property, DbModel model)
{
Debug.Assert(property != null, "property is null.");
Debug.Assert(model != null, "model is null.");
if (!_precisionTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
{
// Doesn't apply
return null;
}
var storeProperty = model.GetColumn(property);
var defaultPrecision = (byte)storeProperty.PrimitiveType.FacetDescriptions
.First(d => d.FacetName == DbProviderManifest.PrecisionFacetName).DefaultValue;
// NOTE: This facet is not propagated to the conceptual side of the reverse
// engineered model.
var precision = storeProperty.Precision ?? defaultPrecision;
if (precision == defaultPrecision)
{
// By convention
return null;
}
return new PrecisionDateTimeConfiguration { Precision = precision };
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:27,代码来源:PrecisionDateTimeDiscoverer.cs
示例13: BuildColumnMapping
private void BuildColumnMapping(string identity, EdmProperty property, string propertyName, ColumnMapping columnMapping)
{
if (_primaryKeysMapping[identity].Contains(propertyName))
{
columnMapping.IsPk = true;
}
foreach (var facet in property.TypeUsage.Facets)
{
switch (facet.Name)
{
case "Nullable":
columnMapping.Nullable = (bool)facet.Value;
break;
case "DefaultValue":
columnMapping.DefaultValue = facet.Value;
break;
case "StoreGeneratedPattern":
columnMapping.IsIdentity = (StoreGeneratedPattern)facet.Value == StoreGeneratedPattern.Identity;
columnMapping.Computed = (StoreGeneratedPattern)facet.Value == StoreGeneratedPattern.Computed;
break;
case "MaxLength":
columnMapping.MaxLength = (int)facet.Value;
break;
}
}
}
开发者ID:arthuryii,项目名称:WhenEntityFrameworkMeetUnity,代码行数:27,代码来源:DbMapping.cs
示例14: MatchDependentKeyProperty
/// <inheritdoc/>
protected override bool MatchDependentKeyProperty(
AssociationType associationType,
AssociationEndMember dependentAssociationEnd,
EdmProperty dependentProperty,
EntityType principalEntityType,
EdmProperty principalKeyProperty)
{
Check.NotNull(associationType, "associationType");
Check.NotNull(dependentAssociationEnd, "dependentAssociationEnd");
Check.NotNull(dependentProperty, "dependentProperty");
Check.NotNull(principalEntityType, "principalEntityType");
Check.NotNull(principalKeyProperty, "principalKeyProperty");
var otherEnd = associationType.GetOtherEnd(dependentAssociationEnd);
var navigationProperty
= dependentAssociationEnd.GetEntityType().NavigationProperties
.SingleOrDefault(n => n.ResultEnd == otherEnd);
if (navigationProperty == null)
{
return false;
}
return string.Equals(
dependentProperty.Name, navigationProperty.Name + principalKeyProperty.Name,
StringComparison.OrdinalIgnoreCase);
}
开发者ID:hallco978,项目名称:entityframework,代码行数:29,代码来源:NavigationPropertyNameForeignKeyDiscoveryConvention.cs
示例15: GetTypeUsage
internal override TypeUsage GetTypeUsage()
{
if (_typeUsage == null)
{
var listOfProperties = new List<EdmProperty>();
foreach (var property in _properties)
{
var edmProperty = new EdmProperty(property.FQName, property.GetTypeUsage());
edmProperty.AddMetadataProperties(property.OtherContent);
//edmProperty.DeclaringType
listOfProperties.Add(edmProperty);
}
var rowType = new RowType(listOfProperties);
if (Schema.DataModel
== SchemaDataModelOption.EntityDataModel)
{
rowType.DataSpace = DataSpace.CSpace;
}
else
{
Debug.Assert(
Schema.DataModel == SchemaDataModelOption.ProviderDataModel,
"Only DataModel == SchemaDataModelOption.ProviderDataModel is expected");
rowType.DataSpace = DataSpace.SSpace;
}
rowType.AddMetadataProperties(OtherContent);
_typeUsage = TypeUsage.Create(rowType);
}
return _typeUsage;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:32,代码来源:RowTypeElement.cs
示例16: SetDefaultDiscriminator
public static void SetDefaultDiscriminator(
this MappingFragment entityTypeMappingFragment, EdmProperty discriminator)
{
DebugCheck.NotNull(entityTypeMappingFragment);
entityTypeMappingFragment.Annotations.SetAnnotation(DefaultDiscriminatorAnnotation, discriminator);
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:7,代码来源:StorageMappingFragmentExtensions.cs
示例17: ConditionPropertyMapping
internal ConditionPropertyMapping(EdmProperty propertyOrColumn, object value, bool? isNull)
{
DebugCheck.NotNull(propertyOrColumn);
Debug.Assert((isNull.HasValue) || (value != null), "Either Value or IsNull has to be specified on Condition Mapping");
Debug.Assert(!(isNull.HasValue) || (value == null), "Both Value and IsNull can not be specified on Condition Mapping");
var dataSpace = propertyOrColumn.TypeUsage.EdmType.DataSpace;
switch (dataSpace)
{
case DataSpace.CSpace:
base.Property = propertyOrColumn;
break;
case DataSpace.SSpace:
_column = propertyOrColumn;
break;
default:
throw new ArgumentException(
Strings.MetadataItem_InvalidDataSpace(dataSpace, typeof(EdmProperty).Name),
"propertyOrColumn");
}
_value = value;
_isNull = isNull;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:27,代码来源:ConditionPropertyMapping.cs
示例18: ColumnMappingBuilder
public ColumnMappingBuilder(EdmProperty columnProperty, IList<EdmProperty> propertyPath)
{
Check.NotNull(columnProperty, "columnProperty");
Check.NotNull(propertyPath, "propertyPath");
_columnProperty = columnProperty;
_propertyPath = propertyPath;
}
开发者ID:hallco978,项目名称:entityframework,代码行数:8,代码来源:ColumnMappingBuilder.cs
示例19: ModificationFunctionResultBinding
/// <summary>
/// Initializes a new ModificationFunctionResultBinding instance.
/// </summary>
/// <param name="columnName">The name of the column to bind from the function result set.</param>
/// <param name="property">The property to be set on the entity.</param>
public ModificationFunctionResultBinding(string columnName, EdmProperty property)
{
Check.NotNull(columnName, "columnName");
Check.NotNull(property, "property");
_columnName = columnName;
_property = property;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:ModificationFunctionResultBinding.cs
示例20: StorageModificationFunctionResultBinding
internal StorageModificationFunctionResultBinding(string columnName, EdmProperty property)
{
DebugCheck.NotNull(columnName);
DebugCheck.NotNull(property);
ColumnName = columnName;
Property = property;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:StorageModificationFunctionResultBinding.cs
注:本文中的System.Data.Entity.Core.Metadata.Edm.EdmProperty类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论