public virtual IEnumerable <EntityField> BuildEntityFields <TEntity>( EntityDefinition rootEntityDefinition, EntityDefinition entityDefinition, TypeModel typeModel, IEnumerable <IField> relativeParentFields = null, IEnumerable <IField> fullParentFields = null, IQueryReference source = null ) where TEntity : class { if (source == null) { source = new TableReference(entityDefinition.TableName); } var builder = new EntityFieldBuilder <TEntity>(rootEntityDefinition, entityDefinition, this, relativeParentFields ?? new IField[0], fullParentFields ?? new IField[0], source); foreach (var field in typeModel.Fields) { if (field.IsEnumerableType) { continue; } field.Dispatch(builder); yield return(builder.EntityField); } }
public Join(IQueryReference left, IQueryReference right, string alias) { Left = left; Right = right; _alias = alias; AliasIdentifierExpression = new AliasIdentifierExpression(_alias); }
protected EntityField( string fieldName, bool canRead, bool canWrite, Type fieldDataType, Column column, IEnumerable <EntityField> subFields = null, IQueryReference source = null, bool isPrimaryKey = false ) { FieldName = fieldName; CanRead = canRead; CanWrite = canWrite; FieldDataType = fieldDataType; IsPrimaryKey = isPrimaryKey; Column = column; SubFields = subFields?.ToArray() ?? new EntityField[0]; if (IsPrimaryKey && FieldDataType != typeof(Guid)) { IsSeverGenerated = true; } Source = source; IsEntityLocalField = Source is TableReference; ProjectionAlias = $"__alias_{fieldName}_{_projectionAliasCounter++}"; FieldDataTypeModel = TypeModel.GetModelOf(FieldDataType); }
public abstract IEnumerable <EntityField> BuildEntityFields( IFieldBuilder fieldBuilder, EntityDefinition entityDefinition, TypeModel typeModel, IEnumerable <IField> relativeParentFields = null, IEnumerable <IField> fullParentFields = null, IQueryReference source = null );
protected void AddJoin(IQueryReference queryReference) { var join = queryReference as Join; if (join == null) { return; } _requiredJoins.AddJoin(join); }
public ForeignKeyEntityBuilder( IField modelField, IEnumerable <IField> relativeParentFields, IEnumerable <IField> fullParentFields, IQueryReference source ) { _modelField = modelField; _relativeParentFields = relativeParentFields; _fullParentFields = fullParentFields; _source = source; }
public EntityFieldBuilder(EntityDefinition rootEntityDefinition, EntityDefinition entityDefinition, SchemaBuilder schemaBuilder, IEnumerable <IField> relativeParentFields, IEnumerable <IField> fullParentFields, IQueryReference source) { _rootEntityDefinition = rootEntityDefinition; _entityDefinition = entityDefinition; _schemaBuilder = schemaBuilder; _relativeParentFields = relativeParentFields; _fullParentFields = fullParentFields; _source = source; }
public EntityJoin(IQueryReference left, IQueryReference right, string alias) : base(left, right, alias) { }
public static ReferencedEntityField <T, TEntity> Create(IField modelField, IEnumerable <IField> relativeParentFields, IEnumerable <IField> fullParentFields, IEnumerable <EntityField> subFields, IQueryReference source) { // only create the sub fields once please var subFieldsArray = subFields.ToArray(); var primaryKeyFields = new List <EntityField>(); var foreignKeyBuilder = new ForeignKeyEntityBuilder( modelField, relativeParentFields, fullParentFields, source ); foreach (var subField in subFieldsArray.Where(q => q.IsPrimaryKey)) { subField.Dispatch(foreignKeyBuilder); primaryKeyFields.Add(foreignKeyBuilder.EntityField); } return(new ReferencedEntityField <T, TEntity>( modelField.FieldName, modelField.CanRead, modelField.CanWrite, primaryKeyFields.Concat(subFields), source )); }
public ReferencedEntityField(string fieldName, bool canRead, bool canWrite, IEnumerable <EntityField> subFields, IQueryReference source) : base(fieldName, canRead, canWrite, typeof(T), null, subFields, source) { }
protected EmbeddedEntityField(string fieldName, bool canRead, bool canWrite, Type fieldDataType, Column column, IEnumerable <EntityField> subFields = null, IQueryReference source = null, bool isPrimaryKey = false) : base(fieldName, canRead, canWrite, fieldDataType, column, subFields, source, isPrimaryKey) { }