public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { string tableName = entityInfo.TableName; builder.EntityType = this.schema.GetEntityType(tableName); builder.Name = tableName; }
public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { foreach (EntityPropertyInfo property in entityInfo.Properties) { if (property.Facets.Identity && IsIdentityType(property.ClrType)) { builder.IdentityField = builder.FindMember(property); } } }
public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { foreach (EntityPropertyInfo property in entityInfo.Properties) { if (!property.Facets.Nullable && TypeHelper.IsNullable(property.ClrType)) { MemberInfo member = builder.FindMember(property); object factory = ConstraintFactories.NotNull(member); builder.AddContraintFactory(factory); } } }
public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { foreach (EntityPropertyInfo property in entityInfo.Properties) { if (property.Facets.Identity && property.ClrType == typeof(Guid)) { MemberInfo member = builder.FindMember(property); object factory = ConstraintFactories.GeneratedGuid(member); builder.AddContraintFactory(factory); } } }
public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { IList<PropertyInfo> keyMembers = new List<PropertyInfo>(); foreach (EntityPropertyInfo property in entityInfo.KeyMembers) { PropertyInfo member = builder.FindMember(property); keyMembers.Add(member); } builder.PrimaryKey = KeyInfoHelper.CreateKeyInfo(builder.EntityType, keyMembers.ToArray()); }
private static Type CreateEntityType( EntityInfo entity, ModuleBuilder entityModule) { string cliTypeName = TypeHelper.NormalizeForCliTypeName(entity.TableName); TypeBuilder entityTypeBuilder = entityModule.DefineType(cliTypeName, TypeAttributes.Public); foreach (EntityPropertyInfo property in entity.Properties) { EmitHelper.AddProperty(entityTypeBuilder, property.Name, property.ClrType); } return entityTypeBuilder.CreateType(); }
public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { foreach (EntityPropertyInfo property in entityInfo.Properties) { if (property.ClrType == typeof(string) && property.Facets.LimitedLength) { MemberInfo member = builder.FindMember(property); int length = property.Facets.MaxLength; object factory = ConstraintFactories.VarCharLimit(member, length); builder.AddContraintFactory(factory); } } }
public void Configure(EntityInfo entityInfo, DbTableInfoBuilder builder) { var indexes = entityInfo .Properties .SelectMany(p => p.Indexes, (p, i) => new { Property = p, Index = i }) .GroupBy(x => x.Index.Name); foreach (var indexGroup in indexes) { var index = indexGroup.First().Index; var indexProps = indexGroup .OrderBy(x => x.Index.Order) .Select(x => builder.FindMember(x.Property)) .ToArray(); var keyInfo = KeyInfoHelper.CreateKeyInfo(builder.EntityType, indexProps); builder.AddKey(keyInfo, index.IsUnique); } }