/// <summary> /// /// </summary> /// <param name="q"></param> /// <param name="orderBy"></param> /// <param name="pageSize"></param> /// <param name="pageToken"></param> /// <param name="log"></param> /// <returns></returns> internal IDbQuery ListEmployees1( string q, string orderBy, int?pageSize = null, string pageToken = null, IBdoLog log = null) => DbFluent.SelectQuery("GetMyTables", DbFluent.Table()) .WithLimit(100) .AsDistinct() .WithFields( DbFluent.FieldAsAll(DbFluent.Table("table")), DbFluent.Field("Field1", DbFluent.Table("table")), DbFluent.Field("Field2", DbFluent.Table("table"))) .From( DbFluent.Table(nameof(DbRegionalDirectorate).Substring(2), "schema1").WithAlias("table"), DbFluent.TableAsJoin( DbQueryJoinKind.Left, DbFluent.Table("DbTable1".Substring(2), "schema2").WithAlias("table1"), DbFluent.And( DbFluent.Eq( DbFluent.Field("table1key", DbFluent.Table("table1")), DbFluent.Field(nameof(DbRegionalDirectorate.Code), DbFluent.Table("table"))), DbFluent.Eq( DbFluent.Field("table2key", DbFluent.Table("table2")), DbFluent.Field(nameof(DbRegionalDirectorate.LabelEN), DbFluent.Table("table"))))), DbFluent.TableAsJoin( DbQueryJoinKind.Left, DbFluent.Table("DbTable1".Substring(2), "schema2").WithAlias("table2"), DbFluent.Eq( DbFluent.Field("table1key", DbFluent.Table("table2")), DbFluent.Field("Field1", DbFluent.Table("table")))) ) .Filter( q, DbApiFluent.CreateFilterDefinition( DbApiFluent.CreateFilterClause("startDate", DbFluent.Field("CreationDate", DbFluent.Table("table")), DataOperators.GreaterOrEqual), DbApiFluent.CreateFilterClause("endDate", DbFluent.Field("LastModificationDate", DbFluent.Table("table")), DataOperators.LesserOrEqual), DbApiFluent.CreateFilterClause("code", DbFluent.Field("Code", DbFluent.Table("table")), DataOperators.Equal)), log) .Sort( orderBy, DbApiFluent.CreateSortDefinition( DbApiFluent.CreateSortClause("startDate", DbFluent.Field("CreationDate", DbFluent.Table("table"))), DbApiFluent.CreateSortClause("endDate", DbFluent.Field("LastModificationDate", DbFluent.Table("table"))), DbApiFluent.CreateSortClause("code", DbFluent.Field("Code", DbFluent.Table("table")))), log);
/// <summary> /// /// </summary> /// <param name="builder"></param> public void OnCreating_Test1() { AddTable <DbEmployee>(DbFluent.Table(nameof(DbEmployee).Substring(2), "Mdm")) .AddTable("RegionalDirectorate", DbFluent.Table(nameof(DbRegionalDirectorate).Substring(2), "Mdm")) .AddTable <DbContact>(DbFluent.Table(nameof(DbContact).Substring(2), "Mdm")) .AddRelationship("Employee_RegionalDirectorate", Table <DbEmployee>(), Table("RegionalDirectorate"), (nameof(DbEmployee.EmployeeId), nameof(DbRegionalDirectorate.RegionalDirectorateId))) .AddRelationship <DbEmployee, DbContact>((p => p.MainContactId, q => q.ContactId)) .AddRelationship <DbEmployee, DbContact>("secondary", (p => p.MainContactId, q => q.ContactId)) .AddTuple("Fields_SelectEmployee", DbFluent.FieldAsAll(Table <DbEmployee>()), DbFluent.Field(nameof(DbRegionalDirectorate.RegionalDirectorateId), Table("RegionalDirectorate")), DbFluent.Field(nameof(DbRegionalDirectorate.Code), Table("RegionalDirectorate"))) .AddTuple("Fields_SelectEmployee2", DbFluent.FieldAsAll(Table <DbEmployee>("employee")), DbFluent.Field <DbContact>(p => p.Code, Table <DbContact>("contact")).WithAlias("contactCode"), DbFluent.Field(nameof(DbRegionalDirectorate.RegionalDirectorateId), Table("RegionalDirectorate", "regionalDirectorate")), DbFluent.Field(nameof(DbRegionalDirectorate.Code), Table("RegionalDirectorate", "regionalDirectorate"))) .AddQuery( DbFluent.StoredQuery( DbFluent.SelectQuery(Table <DbEmployee>()) .From( Table <DbEmployee>(), DbFluent.TableAsJoin( DbQueryJoinKind.Left, Table("RegionalDirectorate"), JoinCondition("Employee_RegionalDirectorate"))) .WithFields(Tuple("Fields_SelectEmployee")) .AddIdField(p => DbFluent.FieldAsParameter(nameof(DbEmployee.Code), p.UseParameter("code"))))); }