예제 #1
0
 public void Issue2433Test(
     [IncludeDataSources(TestProvName.AllSQLite, TestProvName.AllPostgreSQL)] string context)
 {
     using (var db = GetDataContext(context))
     {
         using (var itb = db.CreateLocalTable <InventoryResourceDTO>())
         {
             var dto1 = new InventoryResourceDTO
             {
                 ResourceID        = Guid.NewGuid(),
                 Status            = InventoryResourceStatus.Used,
                 ModifiedTimeStamp = DateTime.UtcNow - TimeSpan.FromHours(2),
                 Id = Guid.NewGuid()
             };
             ((DataConnection)db).BulkCopy(new BulkCopyOptions
             {
                 CheckConstraints       = true,
                 BulkCopyType           = BulkCopyType.ProviderSpecific,
                 MaxBatchSize           = 5000,
                 UseInternalTransaction = false,
                 NotifyAfter            = 2000,
                 BulkCopyTimeout        = 0,
                 RowsCopiedCallback     = i =>
                 {
                 }
             },
                                           new[] { dto1 });
         }
     }
 }
예제 #2
0
        public void Issue2468Test(
            [IncludeDataSources(TestProvName.AllSQLite)]
            string context)
        {
            using (var db = (DataConnection)GetDataContext(context))
                using (var itb = db.CreateLocalTable <InventoryResourceDTO>())
                {
                    var dto1 = new InventoryResourceDTO
                    {
                        Color = ColorEnum.Blue, Id = TestData.Guid1, CMYKColor = CMYKEnum.Cyan, Status = StatusEnum.Open
                    };

                    db.Insert(dto1);

                    var list = itb
                               .Where(x =>
                                      x.Color.ToString().Contains("Bl") &&
                                      x.CMYKColor.ToString().Contains("Cya") &&
                                      x.Status.ToString().Contains("en")
                                      )
                               .ToList();

                    Assert.That(list.Count, Is.EqualTo(1));
                }
        }
예제 #3
0
        public void Issue2372Test(
            [IncludeDataSources(true, TestProvName.AllSQLite, TestProvName.AllPostgreSQL)] string context)
        {
            Model.ITestDataContext?db1 = null;
            try
            {
                var ms1  = new MappingSchema();
                var fmb1 = ms1.GetFluentMappingBuilder();
                fmb1.Entity <InventoryResourceDTO>()
                .HasTableName("InventoryResource")
                .Property(e => e.Id).IsPrimaryKey()
                .Property(e => e.Status).HasDataType(DataType.NVarChar);

                var ms2 = new MappingSchema();
                ms2.SetConverter <InventoryResourceStatus, string>((obj) =>
                {
                    return(obj.ToString());
                });
                ms2.SetConverter <InventoryResourceStatus, DataParameter>((obj) =>
                {
                    return(new DataParameter {
                        Value = obj.ToString()
                    });
                });
                ms2.SetConverter <string, InventoryResourceStatus>((txt) =>
                {
                    return((InventoryResourceStatus)Enum.Parse(typeof(InventoryResourceStatus), txt, true));
                });

                var fmb2 = ms2.GetFluentMappingBuilder();
                fmb2.Entity <InventoryResourceDTO>()
                .HasTableName("InventoryResource")
                .Property(e => e.Id).IsPrimaryKey()
                .Property(e => e.Status);

                db1 = GetDataContext(context, ms1);
                db1.DropTable <InventoryResourceDTO>(throwExceptionIfNotExists: false);
                db1.CreateLocalTable <InventoryResourceDTO>();

                using (var db2 = GetDataContext(context, ms2))
                {
                    var dto1 = new InventoryResourceDTO
                    {
                        Status = InventoryResourceStatus.Used,
                        Id     = TestData.Guid1
                    };
                    db2.Insert(dto1);
                }
            }
            finally
            {
                if (db1 != null)
                {
                    db1.Dispose();
                }
            }
        }
예제 #4
0
        public void Issue2375Test(
            [IncludeDataSources(TestProvName.AllSQLite, TestProvName.AllPostgreSQL)] string context)
        {
            using (var db = GetDataContext(context))
            {
                using (var itb = db.CreateLocalTable <InventoryResourceDTO>())
                    using (var lctb = db.CreateLocalTable <WmsLoadCarrierDTO>())
                    {
                        var res = new WmsLoadCarrierDTO {
                            Id = Guid.NewGuid(), ResourceLabel = "b"
                        };
                        db.Insert(res);
                        var dto1 = new InventoryResourceDTO
                        {
                            ResourceID        = res.Id,
                            Status            = InventoryResourceStatus.Used,
                            ModifiedTimeStamp = DateTime.UtcNow - TimeSpan.FromHours(2),
                            Id = Guid.NewGuid()
                        };
                        db.Insert(dto1);
                        var dto2 = new InventoryResourceDTO
                        {
                            ResourceID        = res.Id,
                            Status            = InventoryResourceStatus.Used,
                            ModifiedTimeStamp = DateTime.UtcNow - TimeSpan.FromHours(2),
                            Id = Guid.NewGuid()
                        };
                        db.Insert(dto2);

                        var qry = from inventory in itb
                                  join lc in lctb on inventory.ResourceID equals lc.Id
                                  group inventory by new
                        {
                            inventory.Status,
                            lc.ResourceLabel
                        }
                        into grp
                        where grp.Count() > 1
                        select grp;

                        var groups = new List <KeyValuePair <string, IEnumerable <InventoryResourceDTO> > >();

                        foreach (var group in qry)
                        {
                            groups.Add(new KeyValuePair <string, IEnumerable <InventoryResourceDTO> >(group.Key.ResourceLabel, group.OrderBy(x => x.ModifiedTimeStamp).ToList()));
                        }

                        var sql = ((DataConnection)db).LastQuery;
                    }
            }
        }