public async Task Scenario() { await UnitOfWorkHelper.ExecAsync(uow => { foreach (var i in ExpandLinqSumTypeTestHelper.GenerateTestData(() => new DataItem())) { uow.Save(i); } uow.CommitChanges(); ExpandLinqSumTypeTestHelper.Run(uow.Query <DataItem>()); }); }
public void Scenario() { StaticBarrier.Run(delegate { CustomAccessorCompilers.Register((target, accessorText) => { if (accessorText == OID) { return(Expression.Property( Expression.Convert(target, typeof(DCBaseObject)), OID )); } if (accessorText == LOCK_FILED) { return(Expression.Call( Expression.Convert(target, typeof(PersistentBase)), "GetPropertyValue", null, Expression.Constant(LOCK_FILED) )); } return(null); }); var key = Guid.NewGuid(); UnitOfWorkHelper.Exec(uow => { uow.Save(new MyComponentImpl(uow) { Oid = key, Value = 123 }); uow.CommitChanges(); IQueryable <IMyComponent> interfaceQuery = uow.Query <MyComponentImpl>(); var loadResult = DataSourceLoader.Load(interfaceQuery, new SampleLoadOptions { PrimaryKey = new[] { OID }, RemoteSelect = false, PreSelect = new[] { OID, "Value", LOCK_FILED } }); var item = loadResult.data.Cast <IDictionary <string, object> >().First(); Assert.Equal(key, item[OID]); Assert.Equal(123, item["Value"]); Assert.Equal(0, item[LOCK_FILED]); }); }); }
public async Task Scenario() { await UnitOfWorkHelper.ExecAsync(uow => { foreach (var i in PaginateViaPrimaryKeyTestHelper.CreateTestData <DataItem>()) { uow.Save(i); } uow.CommitChanges(); var query = uow.Query <DataItem>(); PaginateViaPrimaryKeyTestHelper.Run(query); PaginateViaPrimaryKeyTestHelper.Run(query.Select(i => new { i.K1, i.K2 })); }); }
public void Scenario() { UnitOfWorkHelper.Exec(uow => { new DataItem(uow) { ID = 1, Text = "1" }; new DataItem(uow) { ID = 3, Text = "3" }; new DataItem(uow) { ID = 2, Text = "2" }; uow.CommitChanges(); { var loadResult = DataSourceLoader.Load(uow.Query <DataItem>(), new SampleLoadOptions { Skip = 1, Take = 1 }); var data = loadResult.data.Cast <DataItem>().ToArray(); Assert.Equal(2, data[0].ID); } { var projection = uow.Query <DataItem>().Select(i => new { i.Text }); var loadResult = DataSourceLoader.Load(projection, new SampleLoadOptions { Skip = 1, Take = 1 }); dynamic data = loadResult.data.Cast <object>().ToArray(); Assert.Equal("2", data[0].Text); } }); }
public async Task Scenario() { var guid1 = "".PadLeft(32, '1'); var guid2 = "".PadLeft(32, '2'); await UnitOfWorkHelper.ExecAsync(uow => { uow.Save(new DataItem { ID = new Guid(guid1) }); uow.Save(new DataItem { ID = new Guid(guid2) }); uow.CommitChanges(); var loadResult = DataSourceLoader.Load(uow.Query <DataItem>(), new SampleLoadOptions { Filter = new[] { "ID", "<", guid2 }, RequireTotalCount = true }); Assert.Equal(1, loadResult.totalCount); }); }