//public async Task<EntityList<Entities.Emploee>> SayHello(string name, int[] age, Guid id, DateTime birthday) //{ // //var vs = new Entities.Order(); // //vs.CreateById = Guid.Empty; // //await EntityStore.SaveAsync(vs); // return null; //} //[InvokePermission(Permissions.Admin || Permissions.Developer)] //public async Task SayHello(Entities.Emploee emp) //{ // await EntityStore.SaveAsync(emp); //} //public async Task<EntityBase> LoadEmploee(Guid id) //{ // return await EntityStore.LoadAsync<Entities.Emploee>(id); //} //public Task<bool> TypeIdTest() //{ // ulong baseType = 0; // var res = baseType == Entities.Emploee.TypeId; // return Task.FromResult(res); //} //public async Task DeleteTest() //{ // await EntityStore.DeleteAsync<Entities.Emploee>(Guid.Empty); //} //public async Task<object> Test() //{ // var q = new TableScan<Entities.OrgUnit>(); // q.Include(o => o.Parent.Name); // return await q.ToListAsync(); //} //public async Task<object> Test() //{ // var id = Guid.Empty; // var childs = await EntityStore.LoadEntitySetAsync<Entities.OrgUnit, Entities.OrgUnit>(id, t => t.Childs); // return childs; //} //public async Task<object> Test() //{ // var q = new TableScan<Entities.VehicleState>(); // q.Partitions.Equal(t => t.VehicleId, 1); // //q.Partitions.Equal(t => t.CreateTime, new DateTime(2019, 1, 1)); // return await q.ToListAsync(); //} //public async Task<object> Test() //{ // var q = new TableScan<Entities.VehicleState>(); // q.Filter(t => t.Lng > 12f && t.Lat > 20f); // return await q.ToListAsync(); //} //public async Task<object> Test(DateTime date) //{ // var q = new IndexScan<Entities.Emploee, Entities.Emploee.UI_Account_Password>(); // q.Keys.Equal(t => t.Account, "Admin"); // return await q.ToListAsync(); //} // public async Task Test() //{ // var obj = new Entities.City(214000); // obj.Name = "Wuxi"; // await DataStore.DemoDB.SaveAsync(obj); //} // public async Task<object> Test() //{ // var q = new SqlQuery<Entities.City>(); // q.Where(t => t.Code > 1 && t.Code < 10); // return await q.ToListAsync(); //} //public async Task<object> Test() //{ // var q = new SqlQuery<Entities.City>(); // q.Where(t => t.Code > 1 && t.Code < 10); // return await q.ToListAsync(t=> t.Code); //} ///// <summary> ///// 测试更新命令及返回 ///// </summary> //public async Task Test() //{ // var cmd = new SqlUpdateCommand<Entities.City>(); // cmd.Update(t => t.Persons = t.Persons + 1); // cmd.Where(t => t.Code == 1); // var outs = cmd.Output(t => t.Persons); // await DataStore.DemoDB.ExecCommandAsync(cmd); // if (outs.Count == 1 && outs[0] > 1) { } //} /// <summary> /// 测试更新命令及返回 /// </summary> public async Task Test() { var cmd = new SqlUpdateCommand <Entities.City>(); cmd.Update(t => t.Persons = t.Persons + 1); cmd.Where(t => t.Code == 1); var outs = cmd.Output(t => new { t.Persons, t.Code }); await DataStore.DemoDB.ExecCommandAsync(cmd); if (outs.Count == 1 && outs[0].Persons > 1) { } }
public void BuildUpdateTest() { var model = MakeTestSqlModel(); var mockRunntimeContext = new MockRuntimContext(); Runtime.RuntimeContext.Init(mockRunntimeContext, 10410); mockRunntimeContext.AddModel(model); var q = new SqlUpdateCommand(model.Id); q.Update(q.T["Code"].Assign(q.T["Code"] + 1)); q.Where(q.T["Code"] == 2); var outs = q.Output(r => r.GetInt32(0), q.T["Code"]); //var outs = q.Output(r => new { Code = r.GetInt32(0), Name = r.GetString(1) }, q.T["Code"], q.T["Name"]); //outs[0].Code == 3; var store = new PgSqlStore(StoreSettings); var cmd = store.BuidUpdateCommand(q); Assert.True(cmd != null); output.WriteLine(cmd.CommandText); //Update "Emploee" t Set "Code" = "Code" + @p1 Where t."Code" = @p2 RETURNING "Code" }