mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
parent
b320d084fa
commit
10d9090fb4
@ -10,7 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>3.2.602</Version>
|
<Version>3.2.603</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -125,7 +125,7 @@ namespace FreeSql
|
|||||||
await AddOrUpdateNavigateListAsync(item, true, null, cancellationToken);
|
await AddOrUpdateNavigateListAsync(item, true, null, cancellationToken);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
if (_tableIdentitys.Length == 1 && _tableReturnColumns.Length == 1)
|
if (_tableIdentitys.Length == 1)
|
||||||
{
|
{
|
||||||
foreach (var s in data)
|
foreach (var s in data)
|
||||||
await AddPrivAsync(s, false, cancellationToken);
|
await AddPrivAsync(s, false, cancellationToken);
|
||||||
|
@ -128,7 +128,7 @@ namespace FreeSql
|
|||||||
AddOrUpdateNavigateList(item, true, null);
|
AddOrUpdateNavigateList(item, true, null);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
if (_tableIdentitys.Length == 1 && _tableReturnColumns.Length == 1)
|
if (_tableIdentitys.Length == 1)
|
||||||
{
|
{
|
||||||
foreach (var s in data)
|
foreach (var s in data)
|
||||||
AddPriv(s, false);
|
AddPriv(s, false);
|
||||||
|
@ -538,5 +538,14 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||||
|
<summary>
|
||||||
|
批量注入 Repository,可以参考代码自行调整
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="globalDataFilter"></param>
|
||||||
|
<param name="assemblies"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -10,7 +10,7 @@ namespace FreeSql.Tests
|
|||||||
public class RepositoryTests
|
public class RepositoryTests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更一条无法更新。
|
/// 更一条无法更新。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -70,12 +70,12 @@ namespace FreeSql.Tests
|
|||||||
repos.Attach(item);
|
repos.Attach(item);
|
||||||
|
|
||||||
item.Title = "xxx";
|
item.Title = "xxx";
|
||||||
repos.Update(item); //这行执行 UPDATE "AddUpdateInfo" SET "Title" = 'xxx' WHERE("Id" = '1942fb53-9700-411d-8895-ce4cecdf3257')
|
repos.Update(item); //这行执行 UPDATE "AddUpdateInfo" SET "Title" = 'xxx' WHERE("Id" = '1942fb53-9700-411d-8895-ce4cecdf3257')
|
||||||
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
||||||
|
|
||||||
repos.Update(item); //这行不执行 SQL,未变化
|
repos.Update(item); //这行不执行 SQL,未变化
|
||||||
|
|
||||||
repos.AttachOnlyPrimary(item).Update(item); //这行更新状态值,只有主键值存在,执行更新 set title = xxx
|
repos.AttachOnlyPrimary(item).Update(item); //这行更新状态值,只有主键值存在,执行更新 set title = xxx
|
||||||
|
|
||||||
Console.WriteLine(repos.UpdateDiy.Where(a => a.Id == item.Id).Set(a => a.Clicks + 1).ToSql());
|
Console.WriteLine(repos.UpdateDiy.Where(a => a.Id == item.Id).Set(a => a.Clicks + 1).ToSql());
|
||||||
repos.UpdateDiy.Where(a => a.Id == item.Id).Set(a => a.Clicks + 1).ExecuteAffrows();
|
repos.UpdateDiy.Where(a => a.Id == item.Id).Set(a => a.Clicks + 1).ExecuteAffrows();
|
||||||
@ -140,7 +140,7 @@ namespace FreeSql.Tests
|
|||||||
var flowRepos = fsql.GetRepository<FlowModel>();
|
var flowRepos = fsql.GetRepository<FlowModel>();
|
||||||
flowRepos.Insert(flow);
|
flowRepos.Insert(flow);
|
||||||
|
|
||||||
//事务添加
|
//事务添加
|
||||||
flow = new FlowModel()
|
flow = new FlowModel()
|
||||||
{
|
{
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@ -192,7 +192,7 @@ namespace FreeSql.Tests
|
|||||||
var uowFlowRepos = uow.GetRepository<FlowModel>();
|
var uowFlowRepos = uow.GetRepository<FlowModel>();
|
||||||
uowFlowRepos.Insert(flow);
|
uowFlowRepos.Insert(flow);
|
||||||
uowFlowRepos.Orm.Select<FlowModel>().ToList();
|
uowFlowRepos.Orm.Select<FlowModel>().ToList();
|
||||||
//不调用commit将不会提交数据库更改
|
//不调用commit将不会提交数据库更改
|
||||||
//uow.Commit();
|
//uow.Commit();
|
||||||
}
|
}
|
||||||
Assert.False(flowRepos.Select.Any(a => a.UserId == 1 && a.Name == "aaa"));
|
Assert.False(flowRepos.Select.Any(a => a.UserId == 1 && a.Name == "aaa"));
|
||||||
@ -241,36 +241,36 @@ namespace FreeSql.Tests
|
|||||||
var cts = new[] {
|
var cts = new[] {
|
||||||
new Cagetory
|
new Cagetory
|
||||||
{
|
{
|
||||||
Name = "分类1",
|
Name = "分类1",
|
||||||
Goodss = new List<Goods>(new[]
|
Goodss = new List<Goods>(new[]
|
||||||
{
|
{
|
||||||
new Goods { Name = "商品1" },
|
new Goods { Name = "商品1" },
|
||||||
new Goods { Name = "商品2" },
|
new Goods { Name = "商品2" },
|
||||||
new Goods { Name = "商品3" }
|
new Goods { Name = "商品3" }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
new Cagetory
|
new Cagetory
|
||||||
{
|
{
|
||||||
Name = "分类2",
|
Name = "分类2",
|
||||||
Goodss = new List<Goods>(new[]
|
Goodss = new List<Goods>(new[]
|
||||||
{
|
{
|
||||||
new Goods { Name = "商品4" },
|
new Goods { Name = "商品4" },
|
||||||
new Goods { Name = "商品5" }
|
new Goods { Name = "商品5" }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
repo.Insert(cts);
|
repo.Insert(cts);
|
||||||
cts[0].Name = "分类11";
|
cts[0].Name = "分类11";
|
||||||
cts[0].Goodss.Clear();
|
cts[0].Goodss.Clear();
|
||||||
cts[1].Name = "分类22";
|
cts[1].Name = "分类22";
|
||||||
cts[1].Goodss.Clear();
|
cts[1].Goodss.Clear();
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
cts[0].Name = "分类111";
|
cts[0].Name = "分类111";
|
||||||
cts[0].Goodss.Clear();
|
cts[0].Goodss.Clear();
|
||||||
cts[0].Goodss.Add(new Goods { Name = "商品33" });
|
cts[0].Goodss.Add(new Goods { Name = "商品33" });
|
||||||
cts[1].Name = "分类222";
|
cts[1].Name = "分类222";
|
||||||
cts[1].Goodss.Clear();
|
cts[1].Goodss.Clear();
|
||||||
cts[1].Goodss.Add(new Goods { Name = "商品55" });
|
cts[1].Goodss.Add(new Goods { Name = "商品55" });
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
|
|
||||||
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
|
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
|
||||||
@ -304,36 +304,36 @@ namespace FreeSql.Tests
|
|||||||
var cts = new[] {
|
var cts = new[] {
|
||||||
new CagetoryLD
|
new CagetoryLD
|
||||||
{
|
{
|
||||||
Name = "分类1",
|
Name = "分类1",
|
||||||
Goodss = new List<GoodsLD>(new[]
|
Goodss = new List<GoodsLD>(new[]
|
||||||
{
|
{
|
||||||
new GoodsLD { Name = "商品1" },
|
new GoodsLD { Name = "商品1" },
|
||||||
new GoodsLD { Name = "商品2" },
|
new GoodsLD { Name = "商品2" },
|
||||||
new GoodsLD { Name = "商品3" }
|
new GoodsLD { Name = "商品3" }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
new CagetoryLD
|
new CagetoryLD
|
||||||
{
|
{
|
||||||
Name = "分类2",
|
Name = "分类2",
|
||||||
Goodss = new List<GoodsLD>(new[]
|
Goodss = new List<GoodsLD>(new[]
|
||||||
{
|
{
|
||||||
new GoodsLD { Name = "商品4" },
|
new GoodsLD { Name = "商品4" },
|
||||||
new GoodsLD { Name = "商品5" }
|
new GoodsLD { Name = "商品5" }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
repo.Insert(cts);
|
repo.Insert(cts);
|
||||||
cts[0].Name = "分类11";
|
cts[0].Name = "分类11";
|
||||||
cts[0].Goodss.Clear();
|
cts[0].Goodss.Clear();
|
||||||
cts[1].Name = "分类22";
|
cts[1].Name = "分类22";
|
||||||
cts[1].Goodss.Clear();
|
cts[1].Goodss.Clear();
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
cts[0].Name = "分类111";
|
cts[0].Name = "分类111";
|
||||||
cts[0].Goodss.Clear();
|
cts[0].Goodss.Clear();
|
||||||
cts[0].Goodss.Add(new GoodsLD { Name = "商品33" });
|
cts[0].Goodss.Add(new GoodsLD { Name = "商品33" });
|
||||||
cts[1].Name = "分类222";
|
cts[1].Name = "分类222";
|
||||||
cts[1].Goodss.Clear();
|
cts[1].Goodss.Clear();
|
||||||
cts[1].Goodss.Add(new GoodsLD { Name = "商品55" });
|
cts[1].Goodss.Add(new GoodsLD { Name = "商品55" });
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
|
|
||||||
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
|
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
|
||||||
@ -369,52 +369,52 @@ namespace FreeSql.Tests
|
|||||||
public void SaveMany_OneToMany()
|
public void SaveMany_OneToMany()
|
||||||
{
|
{
|
||||||
var repo = g.sqlite.GetRepository<Cagetory>();
|
var repo = g.sqlite.GetRepository<Cagetory>();
|
||||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = false; //关闭级联保存功能
|
repo.DbContextOptions.EnableAddOrUpdateNavigateList = false; //关闭级联保存功能
|
||||||
var cts = new[] {
|
var cts = new[] {
|
||||||
new Cagetory
|
new Cagetory
|
||||||
{
|
{
|
||||||
Name = "分类1",
|
Name = "分类1",
|
||||||
Goodss = new List<Goods>(new[]
|
Goodss = new List<Goods>(new[]
|
||||||
{
|
{
|
||||||
new Goods { Name = "商品1" },
|
new Goods { Name = "商品1" },
|
||||||
new Goods { Name = "商品2" },
|
new Goods { Name = "商品2" },
|
||||||
new Goods { Name = "商品3" }
|
new Goods { Name = "商品3" }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
new Cagetory
|
new Cagetory
|
||||||
{
|
{
|
||||||
Name = "分类2",
|
Name = "分类2",
|
||||||
Goodss = new List<Goods>(new[]
|
Goodss = new List<Goods>(new[]
|
||||||
{
|
{
|
||||||
new Goods { Name = "商品4" },
|
new Goods { Name = "商品4" },
|
||||||
new Goods { Name = "商品5" }
|
new Goods { Name = "商品5" }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
repo.Insert(cts);
|
repo.Insert(cts);
|
||||||
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
cts[0].Goodss.RemoveAt(1);
|
cts[0].Goodss.RemoveAt(1);
|
||||||
cts[1].Goodss.RemoveAt(1);
|
cts[1].Goodss.RemoveAt(1);
|
||||||
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
|
|
||||||
cts[0].Name = "分类11";
|
cts[0].Name = "分类11";
|
||||||
cts[0].Goodss.Clear();
|
cts[0].Goodss.Clear();
|
||||||
cts[1].Name = "分类22";
|
cts[1].Name = "分类22";
|
||||||
cts[1].Goodss.Clear();
|
cts[1].Goodss.Clear();
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
cts[0].Name = "分类111";
|
cts[0].Name = "分类111";
|
||||||
cts[0].Goodss.Clear();
|
cts[0].Goodss.Clear();
|
||||||
cts[0].Goodss.Add(new Goods { Name = "商品33" });
|
cts[0].Goodss.Add(new Goods { Name = "商品33" });
|
||||||
cts[1].Name = "分类222";
|
cts[1].Name = "分类222";
|
||||||
cts[1].Goodss.Clear();
|
cts[1].Goodss.Clear();
|
||||||
cts[1].Goodss.Add(new Goods { Name = "商品55" });
|
cts[1].Goodss.Add(new Goods { Name = "商品55" });
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[0], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
repo.SaveMany(cts[1], "Goodss"); //指定保存 Goodss 一对多属性
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -425,42 +425,42 @@ namespace FreeSql.Tests
|
|||||||
var cts = new[] {
|
var cts = new[] {
|
||||||
new CagetoryParent
|
new CagetoryParent
|
||||||
{
|
{
|
||||||
Name = "分类1",
|
Name = "分类1",
|
||||||
Childs = new List<CagetoryParent>(new[]
|
Childs = new List<CagetoryParent>(new[]
|
||||||
{
|
{
|
||||||
new CagetoryParent { Name = "分类1_1" },
|
new CagetoryParent { Name = "分类1_1" },
|
||||||
new CagetoryParent { Name = "分类1_2" },
|
new CagetoryParent { Name = "分类1_2" },
|
||||||
new CagetoryParent { Name = "分类1_3" }
|
new CagetoryParent { Name = "分类1_3" }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
new CagetoryParent
|
new CagetoryParent
|
||||||
{
|
{
|
||||||
Name = "分类2",
|
Name = "分类2",
|
||||||
Childs = new List<CagetoryParent>(new[]
|
Childs = new List<CagetoryParent>(new[]
|
||||||
{
|
{
|
||||||
new CagetoryParent { Name = "分类2_1" },
|
new CagetoryParent { Name = "分类2_1" },
|
||||||
new CagetoryParent { Name = "分类2_2" }
|
new CagetoryParent { Name = "分类2_2" }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //打开级联保存功能
|
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //打开级联保存功能
|
||||||
repo.Insert(cts);
|
repo.Insert(cts);
|
||||||
|
|
||||||
var notreelist1 = repo.Select.ToList();
|
var notreelist1 = repo.Select.ToList();
|
||||||
var treelist1 = repo.Select.ToTreeList();
|
var treelist1 = repo.Select.ToTreeList();
|
||||||
|
|
||||||
//repo.SaveMany(cts[0], "Childs"); //指定保存 Childs 一对多属性
|
//repo.SaveMany(cts[0], "Childs"); //指定保存 Childs 一对多属性
|
||||||
cts[0].Name = "分类11";
|
cts[0].Name = "分类11";
|
||||||
cts[0].Childs.Clear();
|
cts[0].Childs.Clear();
|
||||||
cts[1].Name = "分类22";
|
cts[1].Name = "分类22";
|
||||||
cts[1].Childs.Clear();
|
cts[1].Childs.Clear();
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
cts[0].Name = "分类111";
|
cts[0].Name = "分类111";
|
||||||
cts[0].Childs.Clear();
|
cts[0].Childs.Clear();
|
||||||
cts[0].Childs.Add(new CagetoryParent { Name = "分类1_33" });
|
cts[0].Childs.Add(new CagetoryParent { Name = "分类1_33" });
|
||||||
cts[1].Name = "分类222";
|
cts[1].Name = "分类222";
|
||||||
cts[1].Childs.Clear();
|
cts[1].Childs.Clear();
|
||||||
cts[1].Childs.Add(new CagetoryParent { Name = "分类2_22" });
|
cts[1].Childs.Add(new CagetoryParent { Name = "分类2_22" });
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
var treelist2 = repo.Select.ToTreeList();
|
var treelist2 = repo.Select.ToTreeList();
|
||||||
}
|
}
|
||||||
@ -479,16 +479,16 @@ namespace FreeSql.Tests
|
|||||||
public void EnableAddOrUpdateNavigateList_ManyToMany()
|
public void EnableAddOrUpdateNavigateList_ManyToMany()
|
||||||
{
|
{
|
||||||
var tags = new[] {
|
var tags = new[] {
|
||||||
new Tag { TagName = "流行" },
|
new Tag { TagName = "流行" },
|
||||||
new Tag { TagName = "80后" },
|
new Tag { TagName = "80后" },
|
||||||
new Tag { TagName = "00后" },
|
new Tag { TagName = "00后" },
|
||||||
new Tag { TagName = "摇滚" }
|
new Tag { TagName = "摇滚" }
|
||||||
};
|
};
|
||||||
var ss = new[]
|
var ss = new[]
|
||||||
{
|
{
|
||||||
new Song
|
new Song
|
||||||
{
|
{
|
||||||
Name = "爱你一万年.mp3",
|
Name = "爱你一万年.mp3",
|
||||||
Tags = new List<Tag>(new[]
|
Tags = new List<Tag>(new[]
|
||||||
{
|
{
|
||||||
tags[0], tags[1]
|
tags[0], tags[1]
|
||||||
@ -496,7 +496,7 @@ namespace FreeSql.Tests
|
|||||||
},
|
},
|
||||||
new Song
|
new Song
|
||||||
{
|
{
|
||||||
Name = "李白.mp3",
|
Name = "李白.mp3",
|
||||||
Tags = new List<Tag>(new[]
|
Tags = new List<Tag>(new[]
|
||||||
{
|
{
|
||||||
tags[0], tags[2]
|
tags[0], tags[2]
|
||||||
@ -504,23 +504,23 @@ namespace FreeSql.Tests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
var repo = g.sqlite.GetRepository<Song>();
|
var repo = g.sqlite.GetRepository<Song>();
|
||||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //打开级联保存功能
|
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //打开级联保存功能
|
||||||
repo.Insert(ss);
|
repo.Insert(ss);
|
||||||
|
|
||||||
ss[0].Tags[0].TagName = "流行101";
|
ss[0].Tags[0].TagName = "流行101";
|
||||||
repo.SaveMany(ss[0], "Tags"); //指定保存 Tags 多对多属性
|
repo.SaveMany(ss[0], "Tags"); //指定保存 Tags 多对多属性
|
||||||
|
|
||||||
ss[0].Name = "爱你一万年.mp5";
|
ss[0].Name = "爱你一万年.mp5";
|
||||||
ss[0].Tags.Clear();
|
ss[0].Tags.Clear();
|
||||||
ss[0].Tags.Add(tags[0]);
|
ss[0].Tags.Add(tags[0]);
|
||||||
ss[1].Name = "李白.mp5";
|
ss[1].Name = "李白.mp5";
|
||||||
ss[1].Tags.Clear();
|
ss[1].Tags.Clear();
|
||||||
ss[1].Tags.Add(tags[3]);
|
ss[1].Tags.Add(tags[3]);
|
||||||
repo.Update(ss);
|
repo.Update(ss);
|
||||||
|
|
||||||
ss[0].Name = "爱你一万年.mp4";
|
ss[0].Name = "爱你一万年.mp4";
|
||||||
ss[0].Tags.Clear();
|
ss[0].Tags.Clear();
|
||||||
ss[1].Name = "李白.mp4";
|
ss[1].Name = "李白.mp4";
|
||||||
ss[1].Tags.Clear();
|
ss[1].Tags.Clear();
|
||||||
repo.Update(ss);
|
repo.Update(ss);
|
||||||
}
|
}
|
||||||
@ -553,19 +553,19 @@ namespace FreeSql.Tests
|
|||||||
g.sqlite.Delete<BeginEdit01>().Where("1=1").ExecuteAffrows();
|
g.sqlite.Delete<BeginEdit01>().Where("1=1").ExecuteAffrows();
|
||||||
var repo = g.sqlite.GetRepository<BeginEdit01>();
|
var repo = g.sqlite.GetRepository<BeginEdit01>();
|
||||||
var cts = new[] {
|
var cts = new[] {
|
||||||
new BeginEdit01 { Name = "分类1" },
|
new BeginEdit01 { Name = "分类1" },
|
||||||
new BeginEdit01 { Name = "分类1_1" },
|
new BeginEdit01 { Name = "分类1_1" },
|
||||||
new BeginEdit01 { Name = "分类1_2" },
|
new BeginEdit01 { Name = "分类1_2" },
|
||||||
new BeginEdit01 { Name = "分类1_3" },
|
new BeginEdit01 { Name = "分类1_3" },
|
||||||
new BeginEdit01 { Name = "分类2" },
|
new BeginEdit01 { Name = "分类2" },
|
||||||
new BeginEdit01 { Name = "分类2_1" },
|
new BeginEdit01 { Name = "分类2_1" },
|
||||||
new BeginEdit01 { Name = "分类2_2" }
|
new BeginEdit01 { Name = "分类2_2" }
|
||||||
}.ToList();
|
}.ToList();
|
||||||
repo.Insert(cts);
|
repo.Insert(cts);
|
||||||
|
|
||||||
repo.BeginEdit(cts);
|
repo.BeginEdit(cts);
|
||||||
|
|
||||||
cts.Add(new BeginEdit01 { Name = "分类2_3" });
|
cts.Add(new BeginEdit01 { Name = "分类2_3" });
|
||||||
cts[0].Name = "123123";
|
cts[0].Name = "123123";
|
||||||
cts.RemoveAt(1);
|
cts.RemoveAt(1);
|
||||||
|
|
||||||
@ -577,13 +577,13 @@ namespace FreeSql.Tests
|
|||||||
repo.BeginEdit(cts);
|
repo.BeginEdit(cts);
|
||||||
|
|
||||||
cts.AddRange(new[] {
|
cts.AddRange(new[] {
|
||||||
new BeginEdit01 { Name = "分类1" },
|
new BeginEdit01 { Name = "分类1" },
|
||||||
new BeginEdit01 { Name = "分类1_1" },
|
new BeginEdit01 { Name = "分类1_1" },
|
||||||
new BeginEdit01 { Name = "分类1_2" },
|
new BeginEdit01 { Name = "分类1_2" },
|
||||||
new BeginEdit01 { Name = "分类1_3" },
|
new BeginEdit01 { Name = "分类1_3" },
|
||||||
new BeginEdit01 { Name = "分类2" },
|
new BeginEdit01 { Name = "分类2" },
|
||||||
new BeginEdit01 { Name = "分类2_1" },
|
new BeginEdit01 { Name = "分类2_1" },
|
||||||
new BeginEdit01 { Name = "分类2_2" }
|
new BeginEdit01 { Name = "分类2_2" }
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.Equal(7, repo.EndEdit());
|
Assert.Equal(7, repo.EndEdit());
|
||||||
@ -600,19 +600,19 @@ namespace FreeSql.Tests
|
|||||||
fsql.Delete<BeginEdit02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<BeginEdit02>().Where("1=1").ExecuteAffrows();
|
||||||
var repo = fsql.GetRepository<BeginEdit02>();
|
var repo = fsql.GetRepository<BeginEdit02>();
|
||||||
var cts = new[] {
|
var cts = new[] {
|
||||||
new BeginEdit02 { Name = "分类1" },
|
new BeginEdit02 { Name = "分类1" },
|
||||||
new BeginEdit02 { Name = "分类1_1" },
|
new BeginEdit02 { Name = "分类1_1" },
|
||||||
new BeginEdit02 { Name = "分类1_2" },
|
new BeginEdit02 { Name = "分类1_2" },
|
||||||
new BeginEdit02 { Name = "分类1_3" },
|
new BeginEdit02 { Name = "分类1_3" },
|
||||||
new BeginEdit02 { Name = "分类2" },
|
new BeginEdit02 { Name = "分类2" },
|
||||||
new BeginEdit02 { Name = "分类2_1" },
|
new BeginEdit02 { Name = "分类2_1" },
|
||||||
new BeginEdit02 { Name = "分类2_2" }
|
new BeginEdit02 { Name = "分类2_2" }
|
||||||
}.ToList();
|
}.ToList();
|
||||||
repo.Insert(cts);
|
repo.Insert(cts);
|
||||||
|
|
||||||
repo.BeginEdit(cts);
|
repo.BeginEdit(cts);
|
||||||
|
|
||||||
cts.Add(new BeginEdit02 { Name = "分类2_3" });
|
cts.Add(new BeginEdit02 { Name = "分类2_3" });
|
||||||
cts[0].Name = "123123";
|
cts[0].Name = "123123";
|
||||||
cts.RemoveAt(1);
|
cts.RemoveAt(1);
|
||||||
|
|
||||||
@ -624,13 +624,13 @@ namespace FreeSql.Tests
|
|||||||
repo.BeginEdit(cts);
|
repo.BeginEdit(cts);
|
||||||
|
|
||||||
cts.AddRange(new[] {
|
cts.AddRange(new[] {
|
||||||
new BeginEdit02 { Name = "分类1" },
|
new BeginEdit02 { Name = "分类1" },
|
||||||
new BeginEdit02 { Name = "分类1_1" },
|
new BeginEdit02 { Name = "分类1_1" },
|
||||||
new BeginEdit02 { Name = "分类1_2" },
|
new BeginEdit02 { Name = "分类1_2" },
|
||||||
new BeginEdit02 { Name = "分类1_3" },
|
new BeginEdit02 { Name = "分类1_3" },
|
||||||
new BeginEdit02 { Name = "分类2" },
|
new BeginEdit02 { Name = "分类2" },
|
||||||
new BeginEdit02 { Name = "分类2_1" },
|
new BeginEdit02 { Name = "分类2_1" },
|
||||||
new BeginEdit02 { Name = "分类2_2" }
|
new BeginEdit02 { Name = "分类2_2" }
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.Equal(7, repo.EndEdit());
|
Assert.Equal(7, repo.EndEdit());
|
||||||
@ -747,5 +747,69 @@ namespace FreeSql.Tests
|
|||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public bool bool_val { get; set; }
|
public bool bool_val { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertIdentity()
|
||||||
|
{
|
||||||
|
var fsql = g.mysql;
|
||||||
|
fsql.Delete<TaskDetailTeam>().Where("1=1").ExecuteAffrows();
|
||||||
|
|
||||||
|
var repo = fsql.GetRepository<TaskDetailTeam>();
|
||||||
|
|
||||||
|
var team = new TaskDetailTeam();
|
||||||
|
repo.Insert(team);
|
||||||
|
|
||||||
|
team = new TaskDetailTeam
|
||||||
|
{
|
||||||
|
TaskId = 1,
|
||||||
|
UserId = 11,
|
||||||
|
IsYanShou = 1,
|
||||||
|
AccessType = "xxxAccessType1"
|
||||||
|
};
|
||||||
|
repo.Insert(team);
|
||||||
|
|
||||||
|
var teams = new[]
|
||||||
|
{
|
||||||
|
new TaskDetailTeam
|
||||||
|
{
|
||||||
|
TaskId = 2,
|
||||||
|
UserId = 22,
|
||||||
|
IsYanShou = 2,
|
||||||
|
AccessType = "xxxAccessType2"
|
||||||
|
},new TaskDetailTeam
|
||||||
|
{
|
||||||
|
TaskId = 3,
|
||||||
|
UserId = 33,
|
||||||
|
IsYanShou = 3,
|
||||||
|
AccessType = "xxxAccessType3"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
repo.Insert(teams);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table(Name = "task_detail_team")]
|
||||||
|
public class TaskDetailTeam
|
||||||
|
{
|
||||||
|
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "createdAt", DbType = "datetime", ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "taskId")]
|
||||||
|
public int TaskId { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "updatedAt", DbType = "datetime", ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "userId")]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "is_yanshou")]
|
||||||
|
public int IsYanShou { get; set; }
|
||||||
|
|
||||||
|
[Column(IsIgnore = true)]
|
||||||
|
public string AccessType { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user