本文整理汇总了C#中System.Data.Metadata.Edm.EdmProperty类的典型用法代码示例。如果您正苦于以下问题:C# EdmProperty类的具体用法?C# EdmProperty怎么用?C# EdmProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmProperty类属于System.Data.Metadata.Edm命名空间,在下文中一共展示了EdmProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsServerGenerated
private static bool IsServerGenerated(EdmProperty property) {
MetadataProperty generated;
if (property.MetadataProperties.TryGetValue(StoreGeneratedMetadata, false, out generated)) {
return "Identity" == (string)generated.Value || "Computed" == (string)generated.Value;
}
return false;
}
示例2: FunctionImportMappingComposable
internal FunctionImportMappingComposable(
EdmFunction functionImport,
EdmFunction targetFunction,
List<Tuple<StructuralType, List<StorageConditionPropertyMapping>, List<StoragePropertyMapping>>> structuralTypeMappings,
EdmProperty[] targetFunctionKeys,
StorageMappingItemCollection mappingItemCollection,
string sourceLocation,
LineInfo lineInfo)
: base(functionImport, targetFunction)
{
EntityUtil.CheckArgumentNull(mappingItemCollection, "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<EdmType>(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;
m_sourceLocation = sourceLocation;
m_lineInfo = lineInfo;
}
示例3: GetStoreType
public override string GetStoreType(EdmProperty property)
{
if (property.TypeUsage.EdmType.Name == "int")
return "INTEGER";
return base.GetStoreType(property);
}
示例4: GetGenerationOption
public string GetGenerationOption(EdmProperty property, EntityType entity)
{
string result = "";
bool isPk = entity.KeyMembers.Contains(property);
MetadataProperty storeGeneratedPatternProperty = null;
string storeGeneratedPatternPropertyValue = "None";
if (property.MetadataProperties.TryGetValue(MetadataConstants.EDM_ANNOTATION_09_02 + ":StoreGeneratedPattern", false, out storeGeneratedPatternProperty))
storeGeneratedPatternPropertyValue = storeGeneratedPatternProperty.Value.ToString();
PrimitiveType edmType = (PrimitiveType)property.TypeUsage.EdmType;
if (edmType == null && property.TypeUsage.EdmType is EnumType)
{
EnumType enumType = property.TypeUsage.EdmType as EnumType;
edmType = enumType.UnderlyingType;
}
if (storeGeneratedPatternPropertyValue == "Computed")
{
result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.Computed))";
}
else if ((edmType.ClrEquivalentType == typeof(int)) || (edmType.ClrEquivalentType == typeof(short)) || (edmType.ClrEquivalentType == typeof(long)))
{
if (isPk && (storeGeneratedPatternPropertyValue != "Identity"))
result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.None))";
else if ((!isPk || (entity.KeyMembers.Count > 1)) && (storeGeneratedPatternPropertyValue == "Identity"))
result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.Identity))";
}
return result;
}
开发者ID:jradxl,项目名称:Entity-Framework-Code-Generation-Tools-Experiments,代码行数:29,代码来源:EF5DbContextFluentMappingLibrary.cs
示例5: StorageModificationFunctionResultBinding
internal StorageModificationFunctionResultBinding(string columnName, EdmProperty property)
{
//Contract.Requires(columnName != null);
//Contract.Requires(property != null);
ColumnName = columnName;
Property = property;
}
示例6: FieldDescriptor
/// <summary>
/// Construct a new instance of the FieldDescriptor class that describes a property
/// on items of the supplied type.
/// </summary>
/// <param name="itemType">Type of object whose property is described by this FieldDescriptor.</param>
/// <param name="isReadOnly">
/// <b>True</b> if property value on item can be modified; otherwise <b>false</b>.
/// </param>
/// <param name="property">
/// EdmProperty that describes the property on the item.
/// </param>
internal FieldDescriptor(Type itemType, bool isReadOnly, EdmProperty property)
: base(property.Name, null)
{
_itemType = itemType;
_property = property;
_isReadOnly = isReadOnly;
_fieldType = DetermineClrType(_property.TypeUsage);
System.Diagnostics.Debug.Assert(_fieldType != null, "FieldDescriptor's CLR type has unexpected value of null.");
}
示例7: WriteCreateColumn
public override string WriteCreateColumn(EdmProperty property, Version targetVersion)
{
var notnull = (property.Nullable ? "" : "NOT NULL");
var identity = GetIdentity(property, targetVersion);
return string.Format("{0} {1} {2} {3}",
FormatName(property.Name),
GetStoreType(property),
identity, notnull).Trim();
}
示例8: StorageScalarPropertyMapping
/// <summary>
/// Construct a new Scalar EdmProperty mapping object
/// </summary>
/// <param name="member"></param>
/// <param name="columnMember"></param>
internal StorageScalarPropertyMapping(EdmProperty member, EdmProperty columnMember)
: base(member) {
Debug.Assert(columnMember != null);
Debug.Assert(
Helper.IsScalarType(member.TypeUsage.EdmType),
"StorageScalarPropertyMapping must only map primitive or enum types");
Debug.Assert(Helper.IsPrimitiveType(columnMember.TypeUsage.EdmType), "StorageScalarPropertyMapping must only map primitive types");
this.m_columnMember = columnMember;
}
示例9: DetermineIsForeignKeyComponent
private bool DetermineIsForeignKeyComponent(EdmProperty property) {
var navigationProperties = property.DeclaringType.Members.OfType<NavigationProperty>();
// Look at all NavigationProperties (i.e. strongly-type relationship columns) of the table this column belong to and
// see if there is a foreign key that matches this property
// If this is a 1 to 0..1 relationship and we are processing the more primary side. i.e in the Student in Student-StudentDetail
// and this is the primary key we don't want to check the relationship type since if there are no constraints we will treat the primary key as a foreign key.
return navigationProperties.Any(n => EFCodeFirstAssociationProvider.GetDependentPropertyNames(n, !IsPrimaryKey /* checkRelationshipType */).Contains(property.Name));
}
示例10: StorageConditionPropertyMapping
/// <summary>
/// Construct a new condition Property mapping object
/// </summary>
/// <param name="cdmMember"></param>
/// <param name="columnMember"></param>
/// <param name="value"></param>
/// <param name="isNull"></param>
internal StorageConditionPropertyMapping(EdmProperty cdmMember, EdmProperty columnMember
, object value, Nullable<bool> isNull) : base(cdmMember) {
Debug.Assert((cdmMember != null) || (columnMember != null), "Both CDM and Column Members can not be specified for Condition Mapping");
Debug.Assert((cdmMember == null) || (columnMember == null), "Either CDM or Column Members has to be specified for Condition Mapping");
Debug.Assert((isNull.HasValue) || (value != null), "Both Value and IsNull can not be specified on Condition Mapping");
Debug.Assert(!(isNull.HasValue) || (value == null), "Either Value or IsNull has to be specified on Condition Mapping");
this.m_columnMember = columnMember;
this.m_value = value;
this.m_isNull = isNull;
}
示例11: StateManagerMemberMetadata
internal StateManagerMemberMetadata(ObjectPropertyMapping memberMap, EdmProperty memberMetadata, bool isPartOfKey)
{
// if memberMap is null, then this is a shadowstate
Debug.Assert(null != memberMap, "shadowstate not supported");
Debug.Assert(null != memberMetadata, "CSpace should never be null");
_clrProperty = memberMap.ClrProperty;
_edmProperty = memberMetadata;
_isPartOfKey = isPartOfKey;
_isComplexType = (Helper.IsEntityType(_edmProperty.TypeUsage.EdmType) ||
Helper.IsComplexType(_edmProperty.TypeUsage.EdmType));
}
示例12: GetStoreType
public override string GetStoreType(EdmProperty property)
{
switch (property.TypeUsage.EdmType.Name)
{
case "datetime":
return "DATE";
case "nvarchar":
return property.ToStoreType().Replace("nvarchar", "VARCHAR");
default:
return base.GetStoreType(property);
}
}
示例13: GenerateColumn
static string GenerateColumn(EdmProperty property)
{
var column = new StringBuilder();
column.Append(SqlGenerator.QuoteIdentifier(property.Name));
column.Append(" ");
column.Append(SqlGenerator.GetSqlPrimitiveType(property.TypeUsage));
if (MetadataHelpers.IsStoreGeneratedIdentity(property))
{
column.Append(" GENERATED BY DEFAULT AS IDENTITY");
}
if (!property.Nullable)
{
column.Append(" NOT NULL");
}
return column.ToString();
}
示例14: GetCorrespondingDependentProperty
/// <summary>
/// Given a property on the principal end of a referential constraint, returns the corresponding property on the dependent end.
/// Requires: The association has a referential constraint, and the specified principalProperty is one of the properties on the principal end.
/// </summary>
public EdmProperty GetCorrespondingDependentProperty(NavigationProperty navProperty, EdmProperty principalProperty)
{
if (navProperty == null)
{
throw new ArgumentNullException("navProperty");
}
if (principalProperty == null)
{
throw new ArgumentNullException("principalProperty");
}
ReadOnlyMetadataCollection<EdmProperty> fromProperties = GetPrincipalProperties(navProperty);
ReadOnlyMetadataCollection<EdmProperty> toProperties = GetDependentProperties(navProperty);
return toProperties[fromProperties.IndexOf(principalProperty)];
}
示例15: AddPropertyMapping
/// <summary>
/// Add a mapping from the propertyRef (of the old type) to the
/// corresponding property in the new type.
///
/// NOTE: Only to be used by StructuredTypeInfo
/// </summary>
/// <param name="propertyRef"></param>
/// <param name="newProperty"></param>
internal void AddPropertyMapping(PropertyRef propertyRef, EdmProperty newProperty)
{
m_propertyMap[propertyRef] = newProperty;
if (propertyRef is TypeIdPropertyRef)
{
m_typeIdProperty = newProperty;
}
else if (propertyRef is EntitySetIdPropertyRef)
{
m_entitySetIdProperty = newProperty;
}
else if (propertyRef is NullSentinelPropertyRef)
{
m_nullSentinelProperty = newProperty;
}
}