## v0.3.21

- 增加 IUpdate IgnoreColumns 重载方法,支持传入字符串数组忽略修改;
- 完善 FreeSql.DbContext,支持对象操作 + SaveChanges 最后保存操作;
This commit is contained in:
28810
2019-03-21 05:24:50 +08:00
parent d9de8e986b
commit c20a0bbd54
24 changed files with 815 additions and 48 deletions

View File

@ -28,19 +28,70 @@ namespace dbcontext_01.Controllers
try {
using (var ctx = new SongContext()) {
id = await ctx.Songs.Insert(new Song { }).ExecuteIdentityAsync();
var song = new Song { };
ctx.Songs.Add(song);
id = song.Id;
var item = await ctx.Songs.Select.Where(a => a.Id == id).FirstAsync();
var adds = Enumerable.Range(0, 100)
.Select(a => new Song { Create_time = DateTime.Now, Is_deleted = false, Title = "xxxx" + a, Url = "url222" })
.ToList();
ctx.Songs.AddRange(adds);
throw new Exception("回滚");
for (var a = 0; a < adds.Count; a++)
adds[a].Title = "dkdkdkdk" + a;
ctx.Songs.UpdateRange(adds);
ctx.Songs.RemoveRange(adds.Skip(10).Take(20).ToList());
//ctx.Songs.Update(adds.First());
adds.Last().Url = "skldfjlksdjglkjjcccc";
ctx.Songs.Update(adds.Last());
//throw new Exception("回滚");
ctx.SaveChanges();
}
using (var ctx = new SongContext()) {
var song = new Song { };
await ctx.Songs.AddAsync(song);
id = song.Id;
var adds = Enumerable.Range(0, 100)
.Select(a => new Song { Create_time = DateTime.Now, Is_deleted = false, Title = "xxxx" + a, Url = "url222" })
.ToList();
await ctx.Songs.AddRangeAsync(adds);
for (var a = 0; a < adds.Count; a++)
adds[a].Title = "dkdkdkdk" + a;
ctx.Songs.UpdateRange(adds);
ctx.Songs.RemoveRange(adds.Skip(10).Take(20).ToList());
//ctx.Songs.Update(adds.First());
adds.Last().Url = "skldfjlksdjglkjjcccc";
ctx.Songs.Update(adds.Last());
//throw new Exception("回滚");
await ctx.SaveChangesAsync();
}
} catch {
var item = await _orm.Select<Song>().Where(a => a.Id == id).FirstAsync();
throw;
}
}
var item22 = await _orm.Select<Song>().Where(a => a.Id == id).FirstAsync();
var item33 = await _orm.Select<Song>().Where(a => a.Id > id).ToListAsync();
return item22.Title;
}
// GET api/values/5
[HttpGet("{id}")]