protected virtual FieldImplementedBy GenerateFieldImplementedBy(ITable table, PropertyRoute route, NameSequence name, bool forceNull, IEnumerable <Type> types) { Type cleanType = Lite.Extract(route.Type) ?? route.Type; string errors = types.Where(t => !cleanType.IsAssignableFrom(t)).ToString(t => t.TypeName(), ", "); if (errors.Length != 0) { throw new InvalidOperationException("Type {0} do not implement {1}".FormatWith(errors, cleanType)); } bool nullable = Settings.IsNullable(route, forceNull) || types.Count() > 1; CombineStrategy strategy = Settings.FieldAttribute <CombineStrategyAttribute>(route)?.Strategy ?? CombineStrategy.Case; bool avoidForeignKey = Settings.FieldAttribute <AvoidForeignKeyAttribute>(route) != null; return(new FieldImplementedBy(route.Type) { SplitStrategy = strategy, ImplementationColumns = types.ToDictionary(t => t, t => new ImplementationColumn { ReferenceTable = Include(t, route), Name = name.Add(TypeLogic.GetCleanName(t)).ToString(), Nullable = nullable, AvoidForeignKey = avoidForeignKey, }), IsLite = route.Type.IsLite(), AvoidExpandOnRetrieving = Settings.FieldAttribute <AvoidExpandQueryAttribute>(route) != null }.Do(f => f.UniqueIndex = f.GenerateUniqueIndex(table, Settings.FieldAttribute <UniqueIndexAttribute>(route)))); }
public CombineStrategyAttribute(CombineStrategy strategy) { this.Strategy = strategy; }
public ImplementedByExpression(Type type, CombineStrategy strategy, IDictionary <Type, EntityExpression> implementations) : base(DbExpressionType.ImplementedBy, type) { this.Implementations = implementations.ToReadOnly(); this.Strategy = strategy; }
public ImplementedByExpression(Type type, CombineStrategy strategy, IDictionary<Type, EntityExpression> implementations) : base(DbExpressionType.ImplementedBy, type) { this.Implementations = implementations.ToReadOnly(); this.Strategy = strategy; }