Update readme.md

This commit is contained in:
2881099 2019-04-27 05:28:21 +08:00 committed by GitHub
parent 74a2cf5317
commit 2f0d6be7d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,35 +122,20 @@ public class SongContext : DbContext {
} }
using (var ctx = new SongContext()) { using (var ctx = new SongContext()) {
var song = new Song { };
await ctx.Songs.AddAsync(song);
var id = song.Id;
var adds = Enumerable.Range(0, 100).Select(a => new Song { 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.Last());
var tag = new Tag { var tag = new Tag {
Name = "testaddsublist", Name = "testaddsublist",
Tags = new[] { Tags = new[] {
new Tag { Name = "sub1" }, new Tag { Name = "sub1" },
new Tag { Name = "sub2" }, new Tag { Name = "sub2" },
new Tag { new Tag {
Name = "sub3", Name = "sub3",
Tags = new[] { Tags = new[] {
new Tag { Name = "sub3_01" } new Tag { Name = "sub3_01" }
}
} }
} }
}
}; };
ctx.Tags.Add(tag); ctx.Tags.Add(tag);
await ctx.SaveChangesAsync(); await ctx.SaveChangesAsync();
} }
``` ```
@ -158,20 +143,15 @@ using (var ctx = new SongContext()) {
# DataFilter & Tenant # DataFilter & Tenant
```csharp ```csharp
public IServiceProvider ConfigureServices(IServiceCollection services) { public void ConfigureServices(IServiceCollection services) {
services.AddSingleton<IFreeSql>(fsql);
services.AddMvc(); services.AddSingleton<IFreeSql>(Fsql);
services.AddFreeRepository(filter => filter
var builder = new ContainerBuilder();
builder.RegisterFreeRepository(filter => filter
.Apply<ISoftDelete>("SoftDelete", a => a.IsDeleted == false) .Apply<ISoftDelete>("SoftDelete", a => a.IsDeleted == false)
.Apply<ITenant>("Tenant", a => a.TenantId == 1) .Apply<ITenant>("Tenant", a => a.TenantId == 1)
,
this.GetType().Assembly
); );
builder.Populate(services);
var container = builder.Build();
return new AutofacServiceProvider(container);
} }
``` ```