/// <summary> /// /// </summary> /// <param name="employee"></param> /// <returns></returns> internal IDbQuery UpsertEmployee(EmployeeDto employee) { return(DbFluent.Upsert(Table <DbEmployee>()) .WithQueries( DbFluent.UpdateQuery(Table <DbEmployee>()) .WithFields(q => new[] { DbFluent.FieldAsParameter(nameof(DbEmployee.Code), q.UseParameter("code", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.ByteArrayField), q.UseParameter("ByteArrayField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.DoubleField), q.UseParameter("DoubleField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.DoubleField), q.UseParameter("DoubleField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.DateTimeField), q.UseParameter("DateTimeField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.LongField), q.UseParameter("LongField", DataValueTypes.Date)) }), DbFluent.InsertQuery(Table <DbEmployee>()) .WithFields(q => new[] { DbFluent.FieldAsParameter(nameof(DbEmployee.Code), q.UseParameter("code", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.ByteArrayField), q.UseParameter("ByteArrayField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.DoubleField), q.UseParameter("DoubleField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.DateTimeField), q.UseParameter("DateTimeField", DataValueTypes.Text)), DbFluent.FieldAsParameter(nameof(DbEmployee.LongField), q.UseParameter("LongField", DataValueTypes.Date)) }) .WithParameters( ElementFactory.CreateScalar("code", employee.Code), ElementFactory.CreateScalar("ByteArrayField", employee.ByteArrayField), ElementFactory.CreateScalar("DoubleField", employee.DoubleField), ElementFactory.CreateScalar("DateTimeField", employee.DateTimeField), ElementFactory.CreateScalar("LongField", employee.LongField))) .WithCTE( DbFluent.TableAsQuery( DbFluent.SelectQuery(null) .WithFields(q => new[] { DbFluent.FieldAsParameter(nameof(DbEmployee.Code), q.UseParameter("code", DataValueTypes.Text)) })) .WithAlias("T")) .WithParameters( ElementFactory.CreateScalar("code", employee.Code), ElementFactory.CreateScalar("ByteArrayField", employee.ByteArrayField), ElementFactory.CreateScalar("DoubleField", employee.DoubleField), ElementFactory.CreateScalar("DateTimeField", employee.DateTimeField), ElementFactory.CreateScalar("LongField", employee.LongField))); }
/// <summary> /// /// </summary> /// <param name="code"></param> /// <returns></returns> internal IDbQuery SelectEmployeeWithCode4(string code) { return(this.UseQuery("SelectEmployeeWithCode4", p => p.SelectQuery <DbEmployee>() .From( DbFluent.TableAsJoin( DbQueryJoinKind.Left, DbFluent.Table("RegionalDirectorate").WithAlias("directorate"), JoinCondition("Employee_RegionalDirectorate", null, "directorate"))) .WithFields(Tuple("Fields_SelectEmployee")) .WithLimit(100) .AddIdField(q => DbFluent.FieldAsParameter(nameof(DbEmployee.Code), q.UseParameter("code", DataValueTypes.Text))) .WithCTE( DbFluent.TableAsQuery( DbFluent.SelectQuery(Table("RegionalDirectorate"))).WithAlias("directorate") )) .WithParameters( ElementFactory.CreateScalar("code", code))); }