Example #1
0
        public Task <TEntity> GetAsync <TEntity>(object param)
            where TEntity : ITableDto
        {
            var query = queryFactory.GetSingleQuery <TEntity>();

            return(uk.DbConnection.QueryFirstOrDefaultAsync <TEntity>(query, param, uk.DbTransaction));
        }
        public Task <TEntity> GetAsync <TEntity>(object param)
            where TEntity : ITableDto
        {
            var query = queryFactory.GetSingleQuery <TEntity>();

            logger.LogDebug("GetAsync query:{query} param:{@param}", query, param);

            return(uk.DbConnection.QueryFirstOrDefaultAsync <TEntity>(query, param, uk.DbTransaction));
        }
        public TEntity Get <TEntity>(object param)
            where TEntity : class
        {
            var query = queryFactory.GetSingleQuery <TEntity>();

            // logger.LogDebug("GetAsync query:{query} param:{@param}", query, param);

            return(Conn.QueryFirstOrDefault <TEntity>(query, param, Tran));
        }
Example #4
0
        public async Task <ProcessHistory> GetAsync(Guid id, bool includeDetails = false)
        {
            ProcessHistoryDto item = default;

            // var sql = $"SELECT " +
            //     $"{string.Join(", ", item.GetColumns().Select(c => c.Key))} " +
            //     $"FROM {item.GetTableName()} " +
            //     $"WHERE {nameof(ProcessHistoryDto.Id)} = @ProcessHistoryId";

            var query = tableQuery.GetSingleQuery <ProcessHistoryDto>();

            item = await DbConnection.QueryFirstAsync <ProcessHistoryDto>(query, new ProcessHistoryDto { Id = id }, DbTransaction);

            item.Interruption = await GetInterruptionHistoryDtoAsync(item.Id);

            if (!string.IsNullOrEmpty(item.ProductSpecificationCode))
            {
                item.ProductSpecification = await GetProductSpecificationDtoAsync(item.ProductSpecificationCode);
            }

            return(mapper.Map <ProcessHistory>(item));
        }
Example #5
0
        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);
        }