public override void Process(EfProcessorContext ctx, EfPropertyDefinition definition)
 {
     if (_providers.All(e => e != ctx.DatabaseContext.Provider))
     {
         ctx.Entity.Ignore(definition.Property.Name); // TODO is this correct or do we use the column name here
     }
 }
Exemplo n.º 2
0
        public override void Process(EfProcessorContext ctx, EfPropertyDefinition definition)
        {
            var k = ctx.Entity.HasAlternateKey(definition.Property.Name);

            if (_name != null)
            {
                k.HasName(_name);                // TODO i dont think this matters
            }
        }
Exemplo n.º 3
0
        public override void Process(EfProcessorContext ctx, IReadOnlyCollection <EfPropertyDefinition> properties)
        {
            var indexParams = properties
                              .Select(def => (prop: def.Property, attr: def.Source as IndexAttribute))
                              .GroupBy(item => item.attr.Name)
                              .Select(group =>
            {
                var first = group.First();
                if (group.Key == null)
                {
                    return(new IndexParam(first.attr, first.prop));
                }

                return(new IndexParam(
                           first.attr,
                           group.OrderBy(item => item.attr.Order).Select(item => item.prop).ToArray()));
            });

            string prefix = null;

            foreach (var indexParam in indexParams)
            {
                var indexBuilder = ctx.Entity
                                   .HasIndex(indexParam.PropertyNames)
                                   .IsUnique(indexParam.IsUnique);
                if (indexParam.IndexName != null)
                {
                    if (indexParam.IsLocal && prefix == null)
                    {
                        prefix = ctx.ClrType.GetCustomAttribute <TableAttribute>()?.Name
                                 ?? throw new EfAttributeException("");

                        indexBuilder.HasName($"{prefix}_{indexParam.IndexName}");
                    }
                    else
                    {
                        indexBuilder.HasName(indexParam.IndexName);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public override void Process(EfProcessorContext ctx, EfPropertyDefinition definition)
 {
     ctx.Entity.Property(definition.Property.Name)
     .HasAnnotation(_annotation, _value);
 }
Exemplo n.º 5
0
 public override bool PropertyMatches(EfProcessorContext ctx, EfPropertyDefinition definition) => true;