public QueryParser(Expression expression = null, TableQueryFactory tableFactory = null) { stream = new ParserStream(tableFactory); base.Visit(expression); var sql = stream.ToString(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var tf = TableQueryFactory.GetInstance(); tf.ConfigureTable <Poco1>("Poco1", ct => { ct.AddColumn(c => c.id, null, false, true); ct.AddColumn(c => c.Name); ct.AddColumn(c => c.Updated); ct.AddColumn(c => c.Enable); }); bool valid = true; var qb1 = new QueryBuilder <Poco1>(); qb1.Where <Poco1>(t => t.id == 2); var qb12 = qb1.Join <Poco2>((t1, t2) => t1.id == t2.id); var qb123 = qb12.Join <Poco3>((t1, t2, t3) => t1.id == t2.id); qb1.Select(t1 => new { t1.id, t1.Name, t1.Enable }); qb12.Select(t1 => t1.id, t2 => t2.Name); qb123.Select(t1 => t1.id, t2 => t2.Name, t3 => t3.IdPoco2); var res22 = qb123.Where <Poco3>(t3 => t3.IdPoco2 == 2); var res21 = qb1.Where2 <Poco3, Poco1>(t3 => t3.Id == 2); // new QueryBuilderOld<Poco>(args => args.Enable); // new QueryBuilderOld<Poco>(args => !args.Enable); // new QueryBuilderOld<Poco>(args => args.Enable == true); // new QueryBuilderOld<Poco>(args => args.Enable != true); // new QueryBuilderOld<Poco>(args => args.Enable == valid); // var queryBuilder = new QueryBuilderOld<Poco>(args => args.id == 3); // queryBuilder // .Where<Poco>(a => a.Enable) // .Select<Poco>(a => new { a.id, a.Name }); // IQueryBuilder<Poco> qbt1 = default; // qbt1 // .Select(a => new { a.Enable, a.id }) // .Where(a => a.Enable); // // // var qbt1t2 = qbt1.Join<Poco, Poco2>((t1, t2) => t1.id == t2.id); // var qbt1t2t3 = qbt1t2.Join<Poco, Poco2, Poco3>((t1, t2 ,t3) => t1.id == t3.id); // // qbt1t2t3 // .Select<Poco2>(a => a.Name) // .Where(a => a.Enable); // List <int> a = new List <int>(); var aa = a.Select(i => i.ToString()); }
public ProcessHistoryRepository(ProcessHistoryUnitOfWork processHistoryUnitOfWork, DowntimeRepositoryMapper mapper, TableQueryFactory tableQuery) { this.processHistoryUnitOfWork = processHistoryUnitOfWork; this.mapper = mapper; this.tableQuery = tableQuery; }
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); }
/// <summary> /// In memory implementation of <see cref="ExecuteQuerySegmentedAsync{T}(TableQuery{T}, TableContinuationToken)"/> /// </summary> public override Task <TableQuerySegment <T> > ExecuteQuerySegmentedAsync <T>(TableQuery <T> query, TableContinuationToken token) { var inputStream = new AntlrInputStream(query.FilterString); var lexer = new QueryFilterLexer(inputStream); var commonTokenStream = new CommonTokenStream(lexer); var parser = new QueryFilterParser(commonTokenStream); var queryContext = parser.query(); var resultNode = new QueryFilterVisitor().Visit(queryContext) as InfixExpressionNode; var astVisitor = new AstVisitor <T>(); var result = astVisitor.VisitInfix(resultNode, _table); var resultList = new List <T>(); foreach (var key in result.Keys) { resultList.AddRange(result[key].Select(kvp => kvp.Value).Cast <T>().ToList()); } var resultSegment = TableQueryFactory.Construct(resultList); return(Task.FromResult(TableQueryFactory.Construct(resultSegment))); }
public DapperRepository(TableQueryFactory queryFactory, IUnitOfWork unitOfWork) { this.queryFactory = queryFactory; this.uk = unitOfWork; }
public DapperRepositoryBase(IUnitOfWork uow, TableQueryFactory queryFactory, ILogger logger = null) { this.UnitOfWork = uow; this.queryFactory = queryFactory; this.logger = logger; }
public DapperRepository(IUnitOfWork unitOfWork, TableQueryFactory queryFactory, ILogger logger = null) { this.queryFactory = queryFactory; this.uk = unitOfWork; this.logger = logger; }
public ParserStream(TableQueryFactory tableFactory = null) { this.tableFactory = tableFactory ?? TableQueryFactory.GetInstance(); }