public IEnumerable <TEntity> GetPagedList <TEntity>( int skipCount = 0, int rowsPerPage = 1000, string whereClause = null, string orderByClause = null, object param = null) where TEntity : class { if (!string.IsNullOrEmpty(whereClause)) { if (!whereClause.TrimStart().StartsWith("WHERE", true, null)) { whereClause = "WHERE " + whereClause.Trim(); } } if (!string.IsNullOrEmpty(orderByClause)) { if (!orderByClause.TrimStart().StartsWith("ORDER BY", true, null)) { orderByClause = "ORDER BY " + orderByClause.Trim(); } } var query = queryFactory.GetPagedListQuery <TEntity>(skipCount, rowsPerPage, whereClause, orderByClause); // logger.LogDebug("GetPagedListAsync query:{query} whereClause:{whereClause} param:{@param}", query, whereClause, param); return(Conn.Query <TEntity>(query, param, Tran)); }
public Task <IEnumerable <TEntity> > GetListAsync <TEntity>(int skipCount = 0, int rowsPerPage = 1000, string whereClause = null, string orderByClause = null, object param = null) where TEntity : ITableDto { var query = queryFactory.GetPagedListQuery <TEntity>(skipCount, rowsPerPage, whereClause, orderByClause); return(uk.DbConnection.QueryAsync <TEntity>(query, param, uk.DbTransaction)); }
public void Test_table_config_builder() { var tablesFactory = new TableQueryFactory(Dialect.SQLite); tablesFactory.ConfigureTable <ProcessHistoryModel>("ProcessHistory", cfgTbl => { ProcessHistoryModel dto = cfgTbl.Table; cfgTbl.AddColumn(nameof(dto.Id), "ProcessHistoryId", false, true); cfgTbl.AddColumn(nameof(dto.StartProcessDateTime)); cfgTbl.AddColumn(nameof(dto.FinishProcessDateTime)); cfgTbl.AddColumn(nameof(dto.ProductSpecificationCode)); }); tablesFactory.ConfigureTable <InterruptionHistoryModel>("InterruptionHistory", cfgTbl => { InterruptionHistoryModel dto = cfgTbl.Table; cfgTbl.AddColumn(nameof(dto.Id), null, true, true); cfgTbl.AddColumn(nameof(dto.ProcessHistoryId)); cfgTbl.AddColumn(nameof(dto.StartDateTime)); cfgTbl.AddColumn(nameof(dto.EndDateTime)); }); tablesFactory.ConfigureTable <ProductSpecificationModel>("ProductSpecification", cfgTbl => { cfgTbl.AddColumn(c => c.Id, null, false, false); cfgTbl.AddColumn(c => c.Code); cfgTbl.AddColumn(c => c.StandarDuration); cfgTbl.AddColumn(c => c.CreatedAt, c => { c.IgnoreInsert = true; c.IgnoreUpdate = true; }); }); var res = tablesFactory.GetPagedListQuery <ProcessHistoryModel>(); res = tablesFactory.GetSingleQuery <ProcessHistoryModel>(); res = tablesFactory.GetDeleteQuery <ProcessHistoryModel>(); res = tablesFactory.GetUpdateQuery <ProcessHistoryModel>(); res = tablesFactory.GetUpdateQuery <ProductSpecificationModel>(); bool isIdentity; var res2 = tablesFactory.GetInsertQuery <ProcessHistoryModel>(); Console.WriteLine(res); }