update internal code

This commit is contained in:
28810 2020-05-23 00:50:24 +08:00
parent fd7d627603
commit 45f06c3025
4 changed files with 18 additions and 14 deletions

View File

@ -257,15 +257,15 @@ new Colorful.Formatter("推荐在实体类目录创建 gen.bat双击它重新
RazorEngine.Engine.Razor.Run(razorId, sw, null, model); RazorEngine.Engine.Razor.Run(razorId, sw, null, model);
StringBuilder plus = new StringBuilder(); StringBuilder plus = new StringBuilder();
plus.AppendLine("//------------------------------------------------------------------------------"); //plus.AppendLine("//------------------------------------------------------------------------------");
plus.AppendLine("// <auto-generated>"); //plus.AppendLine("// <auto-generated>");
plus.AppendLine("// 此代码由工具 FreeSql.Generator 生成。"); //plus.AppendLine("// 此代码由工具 FreeSql.Generator 生成。");
plus.AppendLine("// 运行时版本:" + Environment.Version.ToString()); //plus.AppendLine("// 运行时版本:" + Environment.Version.ToString());
plus.AppendLine("// Website: https://github.com/2881099/FreeSql"); //plus.AppendLine("// Website: https://github.com/2881099/FreeSql");
plus.AppendLine("// 对此文件的更改可能会导致不正确的行为,并且如果"); //plus.AppendLine("// 对此文件的更改可能会导致不正确的行为,并且如果");
plus.AppendLine("// 重新生成代码,这些更改将会丢失。"); //plus.AppendLine("// 重新生成代码,这些更改将会丢失。");
plus.AppendLine("// </auto-generated>"); //plus.AppendLine("// </auto-generated>");
plus.AppendLine("//------------------------------------------------------------------------------"); //plus.AppendLine("//------------------------------------------------------------------------------");
plus.Append(sw.ToString()); plus.Append(sw.ToString());
plus.AppendLine(); plus.AppendLine();

View File

@ -50,6 +50,7 @@ switch (gen.fsql.Ado.DataType) {
break; break;
} }
} }
namespace @gen.NameSpace { namespace @gen.NameSpace {
@if (string.IsNullOrEmpty(gen.table.Comment) == false) { @if (string.IsNullOrEmpty(gen.table.Comment) == false) {
@ -133,6 +134,7 @@ switch (gen.fsql.Ado.DataType) {
break; break;
} }
} }
namespace @gen.NameSpace { namespace @gen.NameSpace {
@if (string.IsNullOrEmpty(gen.table.Comment) == false) { @if (string.IsNullOrEmpty(gen.table.Comment) == false) {

View File

@ -37,7 +37,7 @@ namespace FreeSql
{ {
var db = _resolveDbContext?.Invoke(); var db = _resolveDbContext?.Invoke();
db?.FlushCommand(); db?.FlushCommand();
var select = _originalFsql.Select<T1>().WithTransaction(_resolveUnitOfWork()?.GetOrBeginTransaction(false)); var select = _originalFsql.Select<T1>().WithTransaction(_resolveUnitOfWork?.Invoke()?.GetOrBeginTransaction(false));
if (db?.Options.EnableGlobalFilter == false) select.DisableGlobalFilter(); if (db?.Options.EnableGlobalFilter == false) select.DisableGlobalFilter();
return select; return select;
} }
@ -47,7 +47,7 @@ namespace FreeSql
{ {
var db = _resolveDbContext?.Invoke(); var db = _resolveDbContext?.Invoke();
db?.FlushCommand(); db?.FlushCommand();
var delete = _originalFsql.Delete<T1>().WithTransaction(_resolveUnitOfWork()?.GetOrBeginTransaction()); var delete = _originalFsql.Delete<T1>().WithTransaction(_resolveUnitOfWork?.Invoke()?.GetOrBeginTransaction());
if (db?.Options.EnableGlobalFilter == false) delete.DisableGlobalFilter(); if (db?.Options.EnableGlobalFilter == false) delete.DisableGlobalFilter();
return delete; return delete;
} }
@ -57,7 +57,7 @@ namespace FreeSql
{ {
var db = _resolveDbContext?.Invoke(); var db = _resolveDbContext?.Invoke();
db?.FlushCommand(); db?.FlushCommand();
var update = _originalFsql.Update<T1>().WithTransaction(_resolveUnitOfWork()?.GetOrBeginTransaction()); var update = _originalFsql.Update<T1>().WithTransaction(_resolveUnitOfWork?.Invoke()?.GetOrBeginTransaction());
if (db?.Options.NoneParameter != null) update.NoneParameter(db.Options.NoneParameter.Value); if (db?.Options.NoneParameter != null) update.NoneParameter(db.Options.NoneParameter.Value);
if (db?.Options.EnableGlobalFilter == false) update.DisableGlobalFilter(); if (db?.Options.EnableGlobalFilter == false) update.DisableGlobalFilter();
return update; return update;
@ -68,7 +68,7 @@ namespace FreeSql
{ {
var db = _resolveDbContext?.Invoke(); var db = _resolveDbContext?.Invoke();
db?.FlushCommand(); db?.FlushCommand();
var insert = _originalFsql.Insert<T1>().WithTransaction(_resolveUnitOfWork()?.GetOrBeginTransaction()); var insert = _originalFsql.Insert<T1>().WithTransaction(_resolveUnitOfWork?.Invoke()?.GetOrBeginTransaction());
if (db?.Options.NoneParameter != null) insert.NoneParameter(db.Options.NoneParameter.Value); if (db?.Options.NoneParameter != null) insert.NoneParameter(db.Options.NoneParameter.Value);
return insert; return insert;
} }
@ -76,11 +76,12 @@ namespace FreeSql
public IInsert<T1> Insert<T1>(T1[] source) where T1 : class => Insert<T1>().AppendData(source); public IInsert<T1> Insert<T1>(T1[] source) where T1 : class => Insert<T1>().AppendData(source);
public IInsert<T1> Insert<T1>(List<T1> source) where T1 : class => Insert<T1>().AppendData(source); public IInsert<T1> Insert<T1>(List<T1> source) where T1 : class => Insert<T1>().AppendData(source);
public IInsert<T1> Insert<T1>(IEnumerable<T1> source) where T1 : class => Insert<T1>().AppendData(source); public IInsert<T1> Insert<T1>(IEnumerable<T1> source) where T1 : class => Insert<T1>().AppendData(source);
public IInsertOrUpdate<T1> InsertOrUpdate<T1>() where T1 : class public IInsertOrUpdate<T1> InsertOrUpdate<T1>() where T1 : class
{ {
var db = _resolveDbContext?.Invoke(); var db = _resolveDbContext?.Invoke();
db?.FlushCommand(); db?.FlushCommand();
return _originalFsql.InsertOrUpdate<T1>().WithTransaction(_resolveUnitOfWork()?.GetOrBeginTransaction()); return _originalFsql.InsertOrUpdate<T1>().WithTransaction(_resolveUnitOfWork?.Invoke()?.GetOrBeginTransaction());
} }
} }
} }

View File

@ -52,6 +52,7 @@ public interface IFreeSql : IDisposable
/// Oracle: merge into<para></para> /// Oracle: merge into<para></para>
/// Sqlite: replace into<para></para> /// Sqlite: replace into<para></para>
/// Dameng: merge into<para></para> /// Dameng: merge into<para></para>
/// 注意:还可以使用 FreeSql.Repository 的 InsertOrUpdate 方法
/// </summary> /// </summary>
/// <typeparam name="T1"></typeparam> /// <typeparam name="T1"></typeparam>
/// <returns></returns> /// <returns></returns>