Esempio n. 1
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);
        }