public bool IsMatch(MappingProperty mappingProperty)
 {
     return
         ((mappingProperty.IsTypeOfString() || mappingProperty.IsTypeOfByteArray()) &&
          mappingProperty.HasFacet(DbProviderManifest.FixedLengthFacetName) &&
          mappingProperty.GetFacetValue <bool>(DbProviderManifest.FixedLengthFacetName));
 }
 public bool IsMatch(MappingProperty mappingProperty)
 {
     return
         (mappingProperty.IsTypeOfString() &&
          mappingProperty.HasFacet(DbProviderManifest.UnicodeFacetName) &&
          mappingProperty.GetFacetValue <bool>(DbProviderManifest.UnicodeFacetName));
 }
示例#3
0
 public bool IsMatch(MappingProperty mappingProperty)
 {
     return
         (mappingProperty.IsTypeOfByteArray() &&
          mappingProperty.HasFacet(DbProviderManifest.MaxLengthFacetName) &&
          mappingProperty.GetFacet(DbProviderManifest.MaxLengthFacetName).IsUnbounded == false &&
          mappingProperty.GetFacetValue <int>(DbProviderManifest.MaxLengthFacetName) == 8 &&
          mappingProperty.IsStoreGeneratedComputed);
 }
示例#4
0
        private MappingPropertyView Create(EntityType entityType, MappingProperty mappingProperty)
        {
            var mappingPropertyView = new MappingPropertyView();

            mappingPropertyView.ConceptualName = mappingProperty.Name;
            mappingPropertyView.Attributes.AddRange(
                this.CreateAttributes(entityType, mappingProperty));

            return(mappingPropertyView);
        }
 public bool IsMatch(MappingProperty mappingProperty)
 {
     return
         ((mappingProperty.IsTypeOfString() || mappingProperty.IsTypeOfByteArray()) &&
          mappingProperty.HasFacet(DbProviderManifest.MaxLengthFacetName) &&
          !mappingProperty.GetFacet(DbProviderManifest.MaxLengthFacetName).IsUnbounded&&
          // XXX: I (currently) have no clue how to write a simple test for this.  For some
          // reason a varchar(max) or nvarchar(max) did not have IsUnbounded set, so this
          // match did not fire, and thereby caused the code to emit a superfluous
          // .HasMaxLength(2^31) or .HasMaxLength(2^30) respectively.  The hack (below) is
          // my current work around, but I think it is stupid.
          !this.IsMaxType(mappingProperty.TypeName));
 }
示例#6
0
        private IEnumerable <string> CreateAttributes(EntityType entityType, MappingProperty mappingProperty)
        {
            var mappingViewIsRequired = new MappingPropertyMatcherIsRequired();

            if (mappingViewIsRequired.IsMatch(mappingProperty))
            {
                yield return(".IsRequired()");
            }

            var mappingViewIsFixedLength = new MappingPropertyMatcherIsFixedLength();

            if (mappingViewIsFixedLength.IsMatch(mappingProperty))
            {
                yield return(".IsFixedLength()");
            }

            var mappingViewMaxLength = new MappingPropertyMatcherMaxLength();

            if (mappingViewMaxLength.IsMatch(mappingProperty))
            {
                yield return($".HasMaxLength({mappingViewMaxLength.GetMaxLength(mappingProperty)})");
            }

            var mappingViewIsRowVersion = new MappingPropertyMatcherIsRowVersion();

            if (mappingViewIsRowVersion.IsMatch(mappingProperty))
            {
                yield return(".IsRowVersion()");
            }

            var mappingViewHasStoreGeneratedPattern = new MappingPropertyMatcherHasStoreGeneratedPattern(entityType);

            if (mappingViewHasStoreGeneratedPattern.IsMatch(mappingProperty))
            {
                yield return($".HasDatabaseGeneratedOption(DatabaseGeneratedOption.{mappingViewHasStoreGeneratedPattern.GetStoreGeneratedPattern(mappingProperty)})");
            }
        }
示例#7
0
 private bool IsKey(MappingProperty mappingProperty)
 {
     return(this.entityType.KeyProperties.Any(x => x.Name == mappingProperty.Name));
 }
示例#8
0
 private bool IsStoreGeneratedPatternIdentity(MappingProperty mappingProperty)
 {
     return
         ((!this.IsKey(mappingProperty) || this.HasMultipleKeys()) &&
          mappingProperty.IsStoreGeneratedIdentity);
 }
示例#9
0
 private bool IsStoreGeneratedPatternNone(MappingProperty mappingProperty)
 {
     return
         (this.IsKey(mappingProperty) &&
          !mappingProperty.IsStoreGeneratedIdentity);
 }
示例#10
0
 public StoreGeneratedPattern GetStoreGeneratedPattern(MappingProperty mappingProperty)
 {
     return((this.IsStoreGeneratedPatternNone(mappingProperty)) ?
            StoreGeneratedPattern.None :
            StoreGeneratedPattern.Identity);
 }
示例#11
0
 public bool IsMatch(MappingProperty mappingProperty)
 {
     return
         (mappingProperty.IsTypeOfNumericKey() &&
          (this.IsStoreGeneratedPatternNone(mappingProperty) || this.IsStoreGeneratedPatternIdentity(mappingProperty)));
 }
 public int GetMaxLength(MappingProperty mappingProperty)
 {
     return(mappingProperty.GetFacetValue <int>(DbProviderManifest.MaxLengthFacetName));
 }