diff --git a/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositoryAsync.cs b/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositoryAsync.cs index b53564c79..2a2026fe0 100644 --- a/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositoryAsync.cs +++ b/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositoryAsync.cs @@ -53,7 +53,7 @@ async Task> InsertWithinBoundaryStaticAsync(string boundaryName, IB bool LocalCanInsert(Type entityType, object entity, bool isadd) { var stateKey = rootRepository.Orm.GetEntityKeyString(entityType, entity, false); - if (stateKey == null) return true; + if (string.IsNullOrEmpty(stateKey)) return true; if (ignores.TryGetValue(entityType, out var stateKeys) == false) { if (isadd) diff --git a/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositorySync.cs b/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositorySync.cs index 2643c87cb..5bd551538 100644 --- a/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositorySync.cs +++ b/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepositorySync.cs @@ -106,7 +106,7 @@ static List InsertWithinBoundaryStatic(string boundaryName, IBaseReposit bool LocalCanInsert(Type entityType, object entity, bool isadd) { var stateKey = rootRepository.Orm.GetEntityKeyString(entityType, entity, false); - if (stateKey == null) return true; + if (string.IsNullOrEmpty(stateKey)) return true; if (ignores.TryGetValue(entityType, out var stateKeys) == false) { if (isadd) diff --git a/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootUtils.cs b/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootUtils.cs index 2f6c8ca45..0327f6560 100644 --- a/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootUtils.cs +++ b/Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootUtils.cs @@ -151,12 +151,12 @@ void LocalCompareEntityValueCollection(Type elementType, IEnumerable collectionB foreach (var item in collectionBefore) { var key = fsql.GetEntityKeyString(elementType, item, false); - if (key != null) dictBefore.Add(key, item); + if (!string.IsNullOrEmpty(key)) dictBefore.Add(key, item); } foreach (var item in collectionAfter) { var key = fsql.GetEntityKeyString(elementType, item, false); - if (key != null) + if (!string.IsNullOrEmpty(key)) { if (dictAfter.ContainsKey(key) == false) dictAfter.Add(key, item); diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml index 197e64800..6c9bef485 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.xml +++ b/FreeSql.DbContext/FreeSql.DbContext.xml @@ -826,14 +826,5 @@ - - - 批量注入 Repository,可以参考代码自行调整 - - - - - - diff --git a/FreeSql.Tests/FreeSql.Tests.DbContext2/AggregateRootRepositoryTest2.cs b/FreeSql.Tests/FreeSql.Tests.DbContext2/AggregateRootRepositoryTest2.cs index 3338f67ee..c2c1affdf 100644 --- a/FreeSql.Tests/FreeSql.Tests.DbContext2/AggregateRootRepositoryTest2.cs +++ b/FreeSql.Tests/FreeSql.Tests.DbContext2/AggregateRootRepositoryTest2.cs @@ -21,6 +21,38 @@ public OrderRepository(IFreeSql fsql, UnitOfWorkManager uowManager) : base(uowMa public override ISelect Select => base.SelectDiy; } + [Fact] + public void Test2() + { + using (var fsql = g.CreateMemory()) + { + new OrderRepository(fsql, null); + var repo = fsql.GetAggregateRootRepository(); + + var order = new Order + { + Field2 = "field2", + Extdata = new OrderExt { Field3 = "field3" }, + //Details = new List + //{ + // new OrderDetail { Field4 = "field4_01", Extdata = new OrderDetailExt { Field5 = "field5_01" } }, + // new OrderDetail { Field4 = "field4_02", Extdata = new OrderDetailExt { Field5 = "field5_02" } }, + // new OrderDetail { Field4 = "field4_03", Extdata = new OrderDetailExt { Field5 = "field5_03" } }, + //}, + }; + repo.Insert(order); //级联插入 + + var findOrder = repo.Select.Where(a => a.Id == order.Id).First(); + findOrder.Details = new List + { + new OrderDetail { Field4 = "field4_01", Extdata = new OrderDetailExt { Field5 = "field5_01" } }, + new OrderDetail { Field4 = "field4_02", Extdata = new OrderDetailExt { Field5 = "field5_02" } }, + new OrderDetail { Field4 = "field4_03", Extdata = new OrderDetailExt { Field5 = "field5_03" } }, + }; + repo.InsertOrUpdate(findOrder); + } + } + [Fact] public void Test1() { @@ -79,11 +111,11 @@ void LocalTest() Field2 = "field2", Extdata = new OrderExt { Field3 = "field3" }, Details = new List - { - new OrderDetail { Field4 = "field4_01", Extdata = new OrderDetailExt { Field5 = "field5_01" } }, - new OrderDetail { Field4 = "field4_02", Extdata = new OrderDetailExt { Field5 = "field5_02" } }, - new OrderDetail { Field4 = "field4_03", Extdata = new OrderDetailExt { Field5 = "field5_03" } }, - }, + { + new OrderDetail { Field4 = "field4_01", Extdata = new OrderDetailExt { Field5 = "field5_01" } }, + new OrderDetail { Field4 = "field4_02", Extdata = new OrderDetailExt { Field5 = "field5_02" } }, + new OrderDetail { Field4 = "field4_03", Extdata = new OrderDetailExt { Field5 = "field5_03" } }, + }, Tags = fsql.Select().Where(a => new[] { 1, 2, 3 }.Contains(a.Id)).ToList() }; repo.Insert(order); //级联插入 diff --git a/FreeSql.Tests/FreeSql.Tests.DbContext2/YonganInfos.cs b/FreeSql.Tests/FreeSql.Tests.DbContext2/YonganInfos.cs new file mode 100644 index 000000000..94452ce42 --- /dev/null +++ b/FreeSql.Tests/FreeSql.Tests.DbContext2/YonganInfos.cs @@ -0,0 +1,435 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Web; +//using Newtonsoft.Json; +//using FreeSql.DataAnnotations; +//using FreeSql; +//using FreeSql.Aop; +//using System.Text.RegularExpressions; +//using System.Runtime.CompilerServices; +//using System.ComponentModel.DataAnnotations; +//using static System.Net.Mime.MediaTypeNames; + +///// +///// YonganInfos 的摘要说明 +///// +//[Table(Name = "yongan_customer")] +//public class YonganInfos : YonganCus +//{ +// #region Property + +// private static IFreeSql freeSql = FreeSQLBulider.Init; + + +// /// +// /// [0-失效][1-有效] +// /// +// [Column(IsIgnore = true)] +// public bool IsValid { get; set; } + +// /// +// /// 一般检查表 +// /// +// [Navigate(nameof(PID))] +// public YonganGen MdlGen { get; set; } + +// /// +// /// 辅助检查表 +// /// +// [Navigate(nameof(PID))] +// public YonganAss MdlAss { get; set; } + +// /// +// /// 化验检查表 +// /// +// [Navigate(nameof(YonganLab.PHYSICALID))] +// public List ListLab { get; set; } + +// /// +// /// 体检建议表 +// /// +// [Navigate(nameof(YonganAdv.PHYSICALID))] +// public List ListAdv { get; set; } +// #endregion + +// #region 数据库交互 +// /// +// /// 数据查询 +// /// +// public YonganInfos() { } +// public YonganInfos(string PID) +// { +// if (PID == null) return; + +// var InfoRepo = freeSql.GetAggregateRootRepository(); +// YonganInfos yonganInfos = InfoRepo +// .Select +// .Where(x => x.PID == PID) +// .First(); +// if (yonganInfos == null) return; + +// this.ModelToModel(yonganInfos, this); +// this.IsValid = true; +// } + + +// /// +// /// 数据同步 +// /// +// public void YonganSync() +// { +// if (!this.IsValid) return; + +// //建立仓库 +// var InfoRepo = freeSql.GetAggregateRootRepository(); +// YonganInfos DBInfos = new YonganInfos(PID); +// //数据同步 +// this.SyncIDCARD(DBInfos); +// //快照数据库中的记录 +// InfoRepo.Attach(DBInfos); +// //对比现在类中的数据 +// //执行插入或更新 +// InfoRepo.InsertOrUpdate(this); +// } + +// #endregion + +// #region 业务交互 +// /// +// /// 登记体检 +// /// +// public void YonganRegister() +// { +// this.PID = this.GeneratePID(); +// this.MdlGen = new YonganGen { IDCARD = this.IDCARD }; +// this.MdlAss = new YonganAss { IDCARD = this.IDCARD }; +// this.IsValid = true; +// this.YonganSync(); +// } + +// /// +// /// 生成建议 +// /// +// public void GenerateAdvise() +// { +// List ListException = freeSql.Select() +// .Where(x => !string.IsNullOrEmpty(x.ValueType)) +// .Where(x => x.IsValid == "1") +// .ToList(); + +// } + +// /// +// /// 检验数据同步 +// /// +// public void ToLabdata(bool isToLab) +// { +// if (isToLab) +// { +// //主表 -> 明细: 数据同步 + +// } +// else +// { +// //明细 -> 主表: 数据同步 + +// } +// } + +// #endregion + +// #region 数据同步 +// public void SyncIDCARD(YonganInfos DBInfos) +// { +// //身份证联动更新 +// if (DBInfos.IDCARD != this.IDCARD) +// { +// this.MdlGen.IDCARD = this.IDCARD; +// this.MdlAss.IDCARD = this.IDCARD; +// this.ListLab.ConvertAll(a => a.IDCARD = this.IDCARD); +// this.ListAdv.ConvertAll(a => a.IDCARD = this.IDCARD); +// } +// } +// #endregion + + +// #region 内部数据处理方法 +// /// +// /// +// /// +// /// +// /// +// /// +// private object ModelToModel(object mdlFrom, object mdlTo) +// { +// Type fromT = mdlFrom.GetType(); +// Type toT = mdlTo.GetType(); +// foreach (PropertyInfo ProTo in toT.GetProperties()) +// { +// foreach (PropertyInfo ProFrom in fromT.GetProperties()) +// { +// if (ProTo.Name.ToUpper().Equals(ProFrom.Name.ToUpper())) +// { +// object Val = ProFrom.GetValue(mdlFrom, null); +// ProTo.SetValue(mdlTo, Val, null); +// break; +// } +// } +// } +// return mdlTo; +// } + +// /// +// /// 生成pid +// /// +// /// +// [MethodImpl(MethodImplOptions.Synchronized)] +// private string GeneratePID() +// { +// //PID = 日期(年月日)8位 + 标志位[02-入职体检]2位 + 自增长4位(共14位) 20230112 02 0001 +// string pid = string.Empty; +// string flagID = "02"; +// string Date = DateTime.Now.ToString("yyyyMMdd"); +// string MaxPID = freeSql.Select() +// .Where(a => a.PID.StartsWith($"{Date}{flagID}") && a.PID.Length == 14) +// .Max(b => b.PID); +// if (string.IsNullOrEmpty(MaxPID)) +// //当天第一位病人 +// pid = $"{Date}{flagID}0001"; +// else +// //后续病人 +// pid = $"{Date}{flagID}{(int.Parse(MaxPID.Substring(MaxPID.Length - 4)) + 1).ToString().PadLeft(4, '0')}"; + +// return pid; +// } + +// /// +// /// 获取导航类型 +// /// +// /// +// public string GetRefType() +// { +// var tbref = freeSql.CodeFirst +// .GetTableByEntity(typeof(YonganInfos)) +// .GetTableRef("MdlAss", true); +// return tbref.RefType.ToString(); +// } +// #endregion + + + + +// #region test方法 + +// public void YonganTest() +// { +// var InfoRepo = freeSql.GetAggregateRootRepository(); +// var LabRepo = freeSql.GetAggregateRootRepository(); + + +// YonganInfos yonganInfos = new YonganInfos("111"); +// InfoRepo.Attach(yonganInfos); + +// //yonganInfos.ListLab.First().ITEMNAME = "rrr"; //单条记录更新✔ +// //yonganInfos.ListLab.ConvertAll(lab => lab.ITEMNAME = "eee"); //多条记录更新✔ +// //yonganInfos.ListLab.Add(new YonganLab {ITEMNAME = "ddd" }); //单条记录Add✔ 存在相同主键则不更新 +// //yonganInfos.ListLab.AddRange(new List //多条记录Add× 仅仅插入第一条 +// //{ +// // new YonganLab{ITEMNAME="e",IDCARD="444"}, +// // new YonganLab{ITEMNAME="f"}, +// //}); + +// yonganInfos.ListLab.Add(new YonganLab { ITEMNAME = "f" }); +// yonganInfos.ListLab.Add(new YonganLab { ITEMNAME = "g" }); +// yonganInfos.ListLab.Add(new YonganLab { ITEMNAME = "h" }); + +// //LabRepo.BeginEdit(yonganInfos.ListLab); +// //yonganInfos.ListLab.Add(new YonganLab { ITEMNAME = "f" } ); +// //yonganInfos.ListLab.Add(new YonganLab { ITEMNAME = "g" } ); +// //yonganInfos.ListLab.Add(new YonganLab { ITEMNAME = "h" } ); +// //LabRepo.EndEdit(); + +// //InfoRepo.Update(yonganInfos); +// InfoRepo.InsertOrUpdate(yonganInfos); +// } + + +// public void YonganTest1() +// { +// //var InfoRepo = freeSql.GetAggregateRootRepository(); +// //InfoRepo.Attach(new YonganInfos("111")); + +// YonganInfos yonganInfos = new YonganInfos("111"); +// yonganInfos.IDCARD = "555"; +// //yonganInfos.ListLab = new List +// //{ +// // new YonganLab{IDCARD=this.IDCARD,ITEMNAME="a"}, +// // new YonganLab{IDCARD=this.IDCARD,ITEMNAME="b"}, +// // new YonganLab{IDCARD=this.IDCARD,ITEMNAME="c"}, +// // new YonganLab{IDCARD=this.IDCARD,ITEMNAME="d"}, +// // new YonganLab{IDCARD=this.IDCARD,ITEMNAME="e"}, +// // new YonganLab{IDCARD=this.IDCARD,ITEMNAME="f"}, +// //}; + +// yonganInfos.YonganSync(); +// } + + +// public void freeTest1() +// { +// var repository = freeSql.GetAggregateRootRepository(); +// var order = repository.Select.Where(a => a.Id == 1).First(); //此时已自动 Attach + +// order.Details = new List +// { +// new OrderDetail { Field4 = "field4_01"}, +// new OrderDetail { Field4 = "field4_02"}, +// new OrderDetail { Field4 = "field4_03"} +// }; +// //order.Details[0].Field4 = "test"; +// repository.InsertOrUpdate(order); + +// } + + +// public void freeTest2() +// { +// var repository = freeSql.GetAggregateRootRepository(); +// var order = freeSql.Select() +// .Where(a => a.Id == 1) +// .First(); //单表数据 + +// repository.Attach(order); //快照时 Comments 是 NULL/EMPTY +// order.Details = new List +// { +// new OrderDetail { Field4 = "field4_01"}, +// new OrderDetail { Field4 = "field4_02"}, +// new OrderDetail { Field4 = "field4_03"} +// }; +// repository.InsertOrUpdate(order); + + +// } + +// #endregion + + +//} + + +//#region testModel + +//class Order +//{ +// [Column(IsIdentity = true)] +// public int Id { get; set; } +// public string Field2 { get; set; } + +// public OrderExt Extdata { get; set; } + +// [Navigate(nameof(OrderDetail.OrderId))] +// public List Details { get; set; } + +// [Navigate(ManyToMany = typeof(OrderTag))] +// public List Tags { get; set; } +//} +//class OrderExt +//{ +// [Key] +// public int OrderId { get; set; } +// public string Field3 { get; set; } + +// public Order Order { get; set; } +//} +//class OrderDetail +//{ +// [Column(IsIdentity = true)] +// public int Id { get; set; } +// public int OrderId { get; set; } +// public string Field4 { get; set; } + +// public OrderDetailExt Extdata { get; set; } +//} +//class OrderDetailExt +//{ +// [Key] +// public int OrderDetailId { get; set; } +// public string Field5 { get; set; } + +// public OrderDetail OrderDetail { get; set; } +//} + + + + +///// +///// 中间表 +///// +//class OrderTag +//{ +// [Key] +// public int OrderId { get; set; } +// [Key] +// public int TagId { get; set; } + +// [Navigate(nameof(OrderId))] +// public Order Order { get; set; } +// [Navigate(nameof(TagId))] +// public Tag Tag { get; set; } +//} +//class Tag +//{ +// [Column(IsIdentity = true)] +// public int Id { get; set; } +// public string Name { get; set; } + +// [Navigate(ManyToMany = typeof(OrderTag))] +// public List Orders { get; set; } +//} + + +////class Order +////{ +//// [Column(IsIdentity = true, IsPrimary = true)] +//// public int Id { get; set; } +//// public string Field2 { get; set; } +//// [Navigate(nameof(OrderComment.OrderId))] +//// public List Comments { get; set; } +////} +//class OrderComment +//{ +// [Column(IsIdentity = true, IsPrimary = true)] +// public int Id { get; set; } +// public int OrderId { get; set; } +// public string Field6 { get; set; } +//} + + + +//[Table(Name = "test_user")] +//public class test_user +//{ +// [Key] +// public int ID { get; set; } + +// public string Name { get; set; } + +// [Navigate(nameof(test_userext.NameId))] +// public List list { get; set; } +//} + + +//[Table(Name = "test_userext")] +//public class test_userext +//{ +// [Key] +// public int UserId { get; set; } +// public int NameId { get; set; } +// public string NameEXT { get; set; } +//} + + + +//#endregion + diff --git a/FreeSql/Extensions/EntityUtilExtensions.cs b/FreeSql/Extensions/EntityUtilExtensions.cs index e0d902fc4..12a27a1cf 100644 --- a/FreeSql/Extensions/EntityUtilExtensions.cs +++ b/FreeSql/Extensions/EntityUtilExtensions.cs @@ -21,7 +21,7 @@ public static class EntityUtilExtensions static ConcurrentDictionary>> _dicGetEntityKeyString = new ConcurrentDictionary>>(); /// - /// 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 null + /// 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 "" /// /// /// diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 8f213e5ce..e9f305fa7 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -1104,85 +1104,9 @@ - - - 动态创建实体类型 - - - - - 配置Class - - 类名 - 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] - - - - - 配置属性 - - 属性名称 - 属性类型 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性默认值 - 属性标记的特性-支持多个 - - - - - 配置父类 - - 父类类型 - - - - - Override属性 - - - - - - Emit动态创建出Class - Type - - - - - - 首字母小写 - - - - - - - 首字母大写 - - - - - 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 null + 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 "" @@ -3359,13 +3283,6 @@ - - - 执行SQL语句,返回更新后的记录 - 注意:此方法只有 Postgresql/SqlServer 有效果 - - - 指定事务对象 @@ -3710,177 +3627,6 @@ - - - 测试数据库是否连接正确,本方法执行如下命令: - MySql/SqlServer/PostgreSQL/达梦/人大金仓/神通: SELECT 1 - Oracle: SELECT 1 FROM dual - - 命令超时设置(秒) - - true: 成功, false: 失败 - - - - 查询,若使用读写分离,查询【从库】条件cmdText.StartsWith("SELECT "),否则查询【主库】 - - - - - - - - - - 查询,ExecuteReaderAsync(dr => {}, "select * from user where age > @age", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - 查询 - - - - - - - - - 查询,ExecuteArrayAsync("select * from user where age > @age", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - 查询 - - - - - - - - - 查询,ExecuteDataSetAsync("select * from user where age > @age; select 2", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - 查询 - - - - - - - - - 查询,ExecuteDataTableAsync("select * from user where age > @age", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - 在【主库】执行 - - - - - - - - - 在【主库】执行,ExecuteNonQueryAsync("delete from user where age > @age", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - 在【主库】执行 - - - - - - - - - 在【主库】执行,ExecuteScalarAsync("select 1 from user where age > @age", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - 执行SQL返回对象集合,QueryAsync<User>("select * from user where age > @age", new SqlParameter { ParameterName = "age", Value = 25 }) - - - - - - - - - - - 执行SQL返回对象集合,QueryAsync<User>("select * from user where age > @age", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - - - 执行SQL返回对象集合,Query<User>("select * from user where age > @age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 }) - - - - - - - - - - - - 执行SQL返回对象集合,Query<User, Address>("select * from user where age > @age; select * from address", new { age = 25 }) - 提示:parms 参数还可以传 Dictionary<string, object> - - - - - - - - 可自定义解析表达式 @@ -4880,12 +4626,6 @@ 超时 - - - 获取资源 - - - 使用完毕后,归还资源 @@ -4961,12 +4701,6 @@ 资源对象 - - - 从对象池获取对象成功的时候触发,通过该方法统计或初始化对象 - - 资源对象 - 归还对象给对象池的时候触发 @@ -5897,28 +5631,6 @@ 请使用 fsql.InsertDict(dict) 方法插入字典数据 - - - 动态构建Class Type - - - - - - 根据字典,创建 table 对应的实体对象 - - - - - - - - 根据实体对象,创建 table 对应的字典 - - - - - C#: that >= between && that <= and @@ -6435,3 +6147,304 @@ +ons.LambadaExpressionExtensions.And``2(System.Linq.Expressions.Expression{System.Func{``0,``1,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1,System.Boolean}})"> + + 使用 and 拼接两个 lambda 表达式 + + + + + + 使用 and 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 将 lambda 表达式取反 + + + true 时生效 + + + + + 使用 and 拼接两个 lambda 表达式 + + + + + + 使用 and 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 将 lambda 表达式取反 + + + true 时生效 + + + + + 使用 and 拼接两个 lambda 表达式 + + + + + + 使用 and 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 将 lambda 表达式取反 + + + true 时生效 + + + + + 使用 and 拼接两个 lambda 表达式 + + + + + + 使用 and 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + + + + 使用 or 拼接两个 lambda 表达式 + + + true 时生效 + + + + + + 将 lambda 表达式取反 + + + true 时生效 + + + + + 生成类似Mongodb的ObjectId有序、不重复Guid + + + + + + 插入数据 + + + + + + + 插入数据,传入实体 + + + + + + + + 插入数据,传入实体数组 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: + MySql 5.6+: on duplicate key update + PostgreSQL 9.4+: on conflict do update + SqlServer 2008+: merge into + Oracle 11+: merge into + Sqlite: replace into + 达梦: merge into + 人大金仓:on conflict do update + 神通:merge into + MsAccess:不支持 + 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) + + + + + + + 修改数据 + + + + + + + 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 查询数据 + + + + + + + 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 删除数据 + + + + + + + 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 开启事务(不支持异步) + v1.5.0 关闭了线程事务超时自动提交的机制 + + 事务体 () => {} + + + + 开启事务(不支持异步) + v1.5.0 关闭了线程事务超时自动提交的机制 + + + 事务体 () => {} + + + + 数据库访问对象 + + + + + 所有拦截方法都在这里 + + + + + CodeFirst 模式开发相关方法 + + + + + DbFirst 模式开发相关方法 + + + + + 全局过滤设置,可默认附加为 Select/Update/Delete 条件 + + + +