Browse Source

Apewer-6.3.6

dev
王厅 4 years ago
parent
commit
22313a7423
  1. 38
      Apewer.Run/Apewer.Run.csproj
  2. 11
      Apewer.Run/_Program.cs
  3. 91
      Apewer/Apewer.csproj
  4. 44
      Apewer/Result.cs
  5. 36
      Apewer/Source/IOrm.cs
  6. 130
      Apewer/Source/MySql.cs
  7. 223
      Apewer/Source/OrmHelper.cs
  8. 14
      Apewer/Source/Query.cs
  9. 4
      Apewer/Source/Record.cs
  10. 119
      Apewer/Source/SqlServer.cs
  11. 119
      Apewer/Source/Sqlite.cs
  12. 4
      Apewer/Source/TableStructure.cs
  13. 93
      Apewer/_Common.props
  14. 4
      Apewer/_Extensions.cs
  15. 3
      ChangeLog.md

38
Apewer.Run/Apewer.Run.csproj

@ -1,38 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!--<TargetFrameworks>net20</TargetFrameworks>-->
<!--<TargetFrameworks>net40</TargetFrameworks>-->
<!--<TargetFrameworks>net461</TargetFrameworks>-->
<TargetFrameworks>net461</TargetFrameworks>
</PropertyGroup>
<!-- .NET Framework 4.6.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net461'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 4.6.1</AssemblyTitle>
<DefineConstants>NETFX;NET461;NET45;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<Reference Include="CustomMarshalers" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.Core" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Security" />
<Reference Include="System.Speech" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Apewer\Apewer.csproj" />
</ItemGroup>
</Project>

11
Apewer.Run/_Program.cs

@ -1,11 +0,0 @@
namespace Apewer.Run
{
class Program
{
static void Main(string[] args) => RuntimeUtility.InvokePublicClass();
}
}

91
Apewer/Apewer.csproj

@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />-->
<Import Project="_Common.props" />
<PropertyGroup>
@ -17,93 +15,4 @@
<Title>Apewer</Title>
</PropertyGroup>
<!-- .NET Standard 2.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
<AssemblyTitle>$(AssemblyName) - .NET Standard 2.1</AssemblyTitle>
<DefineConstants>NETSTD;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<!-- .NET Standard 2.0 -->
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<AssemblyTitle>$(AssemblyName) - .NET Standard 2.0</AssemblyTitle>
<DefineConstants>NETSTD;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<!-- .NET Framework 2.0 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net20'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 2.0</AssemblyTitle>
<DefineConstants>NETFX;NET20;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net20'">
<Reference Include="CustomMarshalers" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Management" />
<Reference Include="System.Security" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<!-- .NET Framework 4.0 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net40'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 4.0</AssemblyTitle>
<DefineConstants>NETFX;NET40;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net40'">
<Reference Include="CustomMarshalers" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.Core" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Security" />
<Reference Include="System.Speech" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" />
</ItemGroup>
<!-- .NET Framework 4.6.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net461'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 4.6.1</AssemblyTitle>
<DefineConstants>NETFX;NET461;NET45;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<Reference Include="CustomMarshalers" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.Core" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Security" />
<Reference Include="System.Speech" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" />
</ItemGroup>
<!-- .NET Core 3.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<AssemblyTitle>$(AssemblyName) - .NET Core 3.1</AssemblyTitle>
<DefineConstants>NETCORE;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<!-- 引用 Microsoft.WindowsDesktop.App 时,不需要 UseWPF 和 UseWindowsForms。-->
<!--<UseWPF>true</UseWPF>-->
<!--<UseWindowsForms>true</UseWindowsForms>-->
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
</ItemGroup>
<!--<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />-->
</Project>

44
Apewer/Result.cs

@ -138,64 +138,62 @@ namespace Apewer
public class Result<T> : IDisposable
{
private static readonly T Default = default(T);
private T _entity = default(T);
private Exception _exception = null;
private int _code = 0;
private string _message = Constant.EmptyString;
/// <summary>对象。</summary>
public T Entity { get { return _entity; } }
public T Entity { get; internal set; }
/// <summary>异常。</summary>
public Exception Exception { get { return _exception; } }
public Exception Exception { get; internal set; }
/// <summary>代码。</summary>
public int Code { get { return _code; } }
public int Code { get; internal set; }
/// <summary>消息,此属性永不为 Null 值,当存在 Exception 时将被 Exception.Message 强制覆盖。</summary>
public string Message { get { return _message; } }
public string Message { get; internal set; }
/// <summary>含有实体对象。</summary>
public bool HasEntity { get { return _entity != null; } }
public bool HasEntity { get { return Entity != null; } }
/// <summary>执行与释放或重置非托管资源关联的应用程序定义的任务。</summary>
public void Dispose()
{
var entity = _entity as IDisposable;
var entity = Entity as IDisposable;
if (entity != null) entity.Dispose();
}
private void Construct(T entity, Exception exception, string message)
{
_entity = entity;
_exception = exception;
_message = message ?? Constant.EmptyString;
if (_exception != null && TextVerifier.IsBlank(_message))
Entity = entity;
Exception = exception;
if (string.IsNullOrEmpty(message))
{
_message = _exception.Message;
if (exception != null)
{
var error = Exception.Message;
if (string.IsNullOrEmpty(error)) error = "存在带有无效消息的异常。";
Message = error;
}
}
else Message = message;
}
/// <summary>创建空结果,不含有实体、消息和异常。</summary>
public Result() { }
/// <summary>创建带有异常的结果。</summary>
public Result(Exception exception) { Construct(Default, exception, null); }
public Result(Exception exception) => Construct(default(T), exception, null);
/// <summary>创建带有实体的结果。</summary>
public Result(T entity) { Construct(entity, null, null); }
public Result(T entity) => Construct(entity, null, null);
/// <summary>创建带有实体和消息的结果。</summary>
public Result(T entity, params string[] message) { Construct(entity, null, TextGenerator.Merge(message)); }
public Result(T entity, params string[] message) => Construct(entity, null, TextGenerator.Merge(message));
/// <summary>创建带有错误消息的结果。</summary>
public static Result<T> Error(params string[] message)
{
var instance = new Result<T>();
var merged = TextGenerator.Merge(message);
instance.Construct(Default, null, merged.IsEmpty() ? "存在无效消息。" : merged);
instance.Construct(default(T), null, merged.IsEmpty() ? "存在无效消息。" : merged);
return instance;
}
@ -203,7 +201,7 @@ namespace Apewer
public static Result<T> Error(Exception exception)
{
var instance = new Result<T>();
instance.Construct(Default, exception, (exception == null ? "存在 NULL 异常。" : null));
instance.Construct(default(T), exception, (exception == null ? "存在 NULL 异常。" : null));
return instance;
}

36
Apewer/Source/IOrm.cs

@ -14,32 +14,58 @@ namespace Apewer.Source
/// <returns>错误信息。当成功时候返回空字符串。</returns>
public string Initialize(Type model);
/// <summary>初始化指定类型,以创建表或增加字段。</summary>
/// <returns>错误信息。当成功时候返回空字符串。</returns>
public string Initialize<T>() where T : IRecord;
/// <summary>插入记录。</summary>
/// <param name="record">要插入的记录实体。</param>
/// <returns>错误信息。当成功时候返回空字符串。</returns>
public string Insert(Record record);
public string Insert(IRecord record);
/// <summary>更新记录。</summary>
/// <param name="record">要插入的记录实体。</param>
/// <returns>错误信息。当成功时候返回空字符串。</returns>
public string Update(Record record);
public string Update(IRecord record);
/// <summary>获取指定类型的主键,按 Flag 属性筛选。</summary>
/// <param name="model">要查询的类型。</param>
/// <param name="flag">要求目标记录具有的 Flag 属性,当指定 0 时忽略此要求。</param>
public Result<List<string>> Keys(Type model, long flag = 0);
/// <summary>获取指定类型的主键,按 Flag 属性筛选。</summary>
/// <param name="model">要查询的类型。</param>
/// <param name="flag">要求目标记录具有的 Flag 属性,当指定 0 时忽略此要求。</param>
public Result<List<string>> Keys<T>(long flag = 0) where T : IRecord;
/// <summary>获取具有指定 Key 的记录,并要求记录具有指定的 Flag 属性。</summary>
/// <param name="model">目标记录的类型。</param>
/// <param name="key">目标记录的主键。</param>
/// <param name="flag">要求目标记录具有的 Flag 属性,当指定 0 时忽略此要求。</param>
public Result<IRecord> Get(Type model, string key, long flag = 0);
/// <summary>获取具有指定 Key 的记录,并要求记录具有指定的 Flag 属性。</summary>
/// <param name="key">目标记录的主键。</param>
/// <param name="flag">要求目标记录具有的 Flag 属性,当指定 0 时忽略此要求。</param>
public Result<T> Get<T>(string key, long flag = 0) where T : Record;
public Result<T> Get<T>(string key, long flag = 0) where T : IRecord;
/// <summary>使用指定语句查询,获取查询结果。</summary>
/// <param name="model">目标记录的类型。</param>
/// <param name="sql">要执行的 SQL 语句。</param>
public Result<List<IRecord>> Query(Type model, string sql);
/// <summary>使用指定语句查询,获取查询结果。</summary>
public Result<List<T>> Query<T>(string sql) where T : Record;
/// <param name="sql">要执行的 SQL 语句。</param>
public Result<List<T>> Query<T>(string sql) where T : IRecord;
/// <summary>查询所有记录。</summary>
/// <param name="model">目标记录的类型。</param>
/// <param name="flag">要求目标记录具有的 Flag 属性,当指定 0 时忽略此要求。</param>
public Result<List<IRecord>> Query(Type model, long flag = 0);
/// <summary>查询所有记录。</summary>
/// <param name="flag">要求目标记录具有的 Flag 属性,当指定 0 时忽略此要求。</param>
public Result<List<T>> Query<T>(long flag = 0) where T : Record;
public Result<List<T>> Query<T>(long flag = 0) where T : IRecord;
}

130
Apewer/Source/MySql.cs

@ -22,7 +22,7 @@ namespace Apewer.Source
public class MySql : IDatabase, IOrm, IDisposable
{
#region fields & properties
#region fields & properties
private const string EmptyString = TextUtility.EmptyString;
@ -70,9 +70,9 @@ namespace Apewer.Source
Pass = pass;
}
#endregion
#endregion
#region 日志。
#region 日志。
/// <summary>获取或设置日志记录。</summary>
public Logger Logger { get; set; }
@ -83,9 +83,9 @@ namespace Apewer.Source
if (logger != null) logger.Error(this, "MySQL", action, ex.GetType().FullName, ex.Message, addtion);
}
#endregion
#endregion
#region methods
#region methods
private string CombineString()
{
@ -244,9 +244,9 @@ namespace Apewer.Source
/// <summary></summary>
public IExecute Execute(string sql) => Execute(sql, null as IEnumerable<IDataParameter>);
#endregion
#endregion
#region ORM
#region ORM
private List<string> FirstColumn(string sql)
{
@ -409,13 +409,13 @@ namespace Apewer.Source
public string Initialize(Type model) => Initialize(model, out string sql);
/// <summary></summary>
public string Initialize<T>() where T : Record => Initialize(typeof(T));
public string Initialize<T>() where T : IRecord => Initialize(typeof(T));
/// <summary></summary>
public string Initialize(Record model) => (model == null) ? "参数无效。" : Initialize(model.GetType());
/// <summary>插入记录。成功时候返回空字符串,发生异常时返回异常信息。</summary>
public string Insert(Record record)
public string Insert(IRecord record)
{
if (record == null) return "参数无效。";
record.FixProperties();
@ -435,7 +435,7 @@ namespace Apewer.Source
/// <para>更新记录,实体中的 Created 和 Key 属性不被更新。成功时返回空字符串,发生异常时返回异常信息。</para>
/// <para>无法更新拥有 Independent 特性的模型。</para>
/// </summary>
public string Update(Record record)
public string Update(IRecord record)
{
if (record == null) return "参数无效。";
record.FixProperties();
@ -455,62 +455,24 @@ namespace Apewer.Source
}
/// <summary></summary>
public Result<List<T>> Query<T>(string sql) where T : Record
{
if (sql.IsEmpty()) return new Result<List<T>>(new ArgumentException());
try
{
// 解析模型,抛出 Exception。
TableStructure.ParseModel(typeof(T));
public Result<List<IRecord>> Query(Type model, string sql) => OrmHelper.Query(this, model, sql);
var query = Query(sql) as Query;
var list = query.Fill<T>();
query.Dispose();
return new Result<List<T>>(list);
}
catch (Exception exception)
{
return new Result<List<T>>(exception);
}
}
/// <summary></summary>
public Result<List<T>> Query<T>(string sql) where T : IRecord => OrmHelper.Query<T>(this, sql);
/// <summary>获取记录。</summary>
public Result<T> Get<T>(string key, long flag = 0) where T : Record
/// <summary>获取所有记录。Flag 为 0 时将忽略 Flag 条件。</summary>
public Result<List<IRecord>> Query(Type model, long flag = 0) => OrmHelper.Query(this, model, (tn) =>
{
var k = TextUtility.SafeKey(key);
if (k.IsEmpty()) new Result<T>(new Exception("参数无效。"));
try
{
var structure = TableStructure.ParseModel(typeof(T));
var sqlflag = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" `_flag`=", flag.ToString(), " and");
var sqlkey = TextUtility.Merge(" `_key`='", k, "'");
var sql = TextUtility.Merge("select * from `", structure.Table, "` where ", sqlflag, sqlkey, " limit 1;");
var result = Query<T>(sql);
var list = result.Entity;
if (list != null && list.Count > 0) return new Result<T>(list[0]);
return new Result<T>(null, "无结果。");
}
catch (Exception exception)
{
return new Result<T>(exception);
}
}
if (flag == 0) return $"select * from `{tn}`; ";
return $"select * from `{tn}` where `_flag`={flag}; ";
});
/// <summary>获取所有记录。Flag 为 0 时将忽略 Flag 条件。</summary>
public Result<List<T>> Query<T>(long flag = 0) where T : Record
public Result<List<T>> Query<T>(long flag = 0) where T : IRecord => OrmHelper.Query<T>(this, (tn) =>
{
try
{
var structure = TableStructure.ParseModel(typeof(T));
var sqlflag = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" where `_flag`=", flag.ToString());
var sql = TextUtility.Merge("select * from `", structure.Table, "`", sqlflag, "; ");
return Query<T>(sql);
}
catch (Exception exception)
{
return new Result<List<T>>(exception);
}
}
if (flag == 0) return $"select * from `{tn}`; ";
return $"select * from `{tn}` where `_flag`={flag}; ";
});
/// <summary>获取记录。</summary>
/// <param name="skip">要跳过的记录数,可用最小值为 0。</param>
@ -531,33 +493,29 @@ namespace Apewer.Source
}
}
/// <summary>获取记录。</summary>
public Result<IRecord> Get(Type model, string key, long flag = 0) => OrmHelper.Get(this, model, key, (tn, sk) =>
{
if (flag == 0) return $"select * from `{tn}` where `_key`='{sk}' limit 1;";
return $"select * from `{tn}` where `_key`='{sk}' and `_flag`={flag} limit 1;";
});
/// <summary>获取记录。</summary>
public Result<T> Get<T>(string key, long flag = 0) where T : IRecord => OrmHelper.Get<T>(this, key, (tn, sk) =>
{
if (flag == 0) return $"select * from `{tn}` where `_key`='{sk}' limit 1;";
return $"select * from `{tn}` where `_key`='{sk}' and `_flag`={flag} limit 1;";
});
/// <summary>>获取指定类型的主键,按 Flag 属性筛选。</summary>
public Result<List<string>> Keys(Type model, long flag = 0)
public Result<List<string>> Keys(Type model, long flag = 0) => OrmHelper.Keys(this, model, (tn) =>
{
if (model != null)
{
try
{
var type = model;
var tn = TableStructure.ParseModel(type).Table;
var where = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" where `_flag`=", flag.ToString());
var sql = $"select `_key` from `{tn}`{where}; ";
using (var query = Query(sql) as Query)
{
var list = query.ReadColumn((r) => TextUtility.Trim(query.Text(r, 0)));
return new Result<List<string>>(list);
}
}
catch (Exception ex)
{
return new Result<List<string>>(ex);
}
}
return new Result<List<string>>(new Exception("参数无效。"));
}
if (flag == 0) return $"select `_key` from `{tn}`;";
return $"select `_key` from `{tn}` where `_flag`={flag};";
});
/// <summary>>获取指定类型的主键,按 Flag 属性筛选。</summary>
public Result<List<string>> Keys<T>(long flag = 0) where T : Record => Keys(typeof(T), flag);
public Result<List<string>> Keys<T>(long flag = 0) where T : IRecord => Keys(typeof(T), flag);
/// <summary>对表添加列,返回错误信息。</summary>
/// <typeparam name="T">记录类型。</typeparam>
@ -611,9 +569,9 @@ namespace Apewer.Source
return error;
}
#endregion
#endregion
#region static
#region static
/// <summary>对文本转义,符合 SQL 安全性。可根据字段类型限制 UTF-8 字节数,默认为 0 时不限制字节数。</summary>
public static string Escape(string text, int bytes = 0)
@ -972,7 +930,7 @@ namespace Apewer.Source
return result;
}
#endregion
#endregion
}

223
Apewer/Source/OrmHelper.cs

@ -0,0 +1,223 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Apewer.Source
{
/// <summary>ORM 帮助程序。</summary>
public static class OrmHelper
{
private static List<T> Convert<T>(List<IRecord> input) where T : IRecord
{
if (input == null) return null;
var output = new List<T>(input.Count);
foreach (var record in input)
{
if (record == null) continue;
var t = (T)record;
output.Add(t);
}
return output;
}
private static Result<T> Convert<T>(Result<IRecord> input) where T : IRecord
{
if (input == null) return null;
var result = new Result<T>();
result.Code = input.Code;
result.Exception = input.Exception;
result.Message = input.Message;
if (input.HasEntity) result.Entity = (T)input.Entity;
return result;
}
private static Result<List<T>> Convert<T>(Result<List<IRecord>> input) where T : IRecord
{
if (input == null) return null;
var result = new Result<List<T>>();
result.Code = input.Code;
result.Exception = input.Exception;
result.Message = input.Message;
result.Entity = Convert<T>(input.Entity);
return result;
}
/// <summary>查询记录。</summary>
/// <param name="database">数据库对象。</param>
/// <param name="model">记录模型。</param>
/// <param name="sql">SQL 语句。</param>
public static Result<List<IRecord>> Query(IDatabase database, Type model, string sql)
{
if (database == null) return Result<List<IRecord>>.Error("数据库无效。");
if (model == null) return Result<List<IRecord>>.Error("模型类型无效。");
if (string.IsNullOrEmpty(sql)) return Result<List<IRecord>>.Error("SQL 语句无效。");
using (var query = database.Query(sql) as Query)
{
if (query == null) return Result<List<IRecord>>.Error("查询实例无效。");
if (query.Exception != null) return Result<List<IRecord>>.Error(query.Exception);
try
{
var list = query.Fill(model);
return new Result<List<IRecord>>(list);
}
catch (Exception ex)
{
return Result<List<IRecord>>.Error(ex);
}
}
}
/// <summary>查询记录。</summary>
/// <typeparam name="T">记录模型。</typeparam>
/// <param name="database">数据库对象。</param>
/// <param name="sql">SQL 语句。</param>
public static Result<List<T>> Query<T>(IDatabase database, string sql) where T : IRecord
{
return Convert<T>(Query(database, typeof(T), sql));
}
/// <summary>查询记录。</summary>
/// <param name="database">数据库对象。</param>
/// <param name="model">记录模型。</param>
/// <param name="sqlGetter">生成 SQL 语句的函数,传入参数为表名。</param>
public static Result<List<IRecord>> Query(IDatabase database, Type model, Func<string, string> sqlGetter)
{
if (sqlGetter == null) return Result<List<IRecord>>.Error("SQL 语句获取函数无效。");
try
{
var tableName = TableStructure.ParseModel(model).Table;
if (string.IsNullOrEmpty(tableName)) return Result<List<IRecord>>.Error("表名无效。");
return Query(database, model, sqlGetter(tableName));
}
catch (Exception ex)
{
return Result<List<IRecord>>.Error(ex);
}
}
/// <summary>查询记录。</summary>
/// <typeparam name="T">记录模型。</typeparam>
/// <param name="database">数据库对象。</param>
/// <param name="sqlGetter">生成 SQL 语句的函数,传入参数为表名。</param>
public static Result<List<T>> Query<T>(IDatabase database, Func<string, string> sqlGetter) where T : IRecord
{
return Convert<T>(Query(database, typeof(T), sqlGetter));
}
/// <summary>获取具有指定主键的记录。</summary>
/// <param name="database">数据库对象。</param>
/// <param name="model">记录模型。</param>
/// <param name="key">主键。</param>
/// <param name="sqlGetter">生成 SQL 语句的函数,传入参数为表名和主键值。</param>
public static Result<IRecord> Get(IDatabase database, Type model, string key, Func<string, string, string> sqlGetter)
{
if (sqlGetter == null) return Result<IRecord>.Error("SQL 语句获取函数无效。");
var safetyKey = TextUtility.SafeKey(key);
if (string.IsNullOrEmpty(safetyKey)) return Result<IRecord>.Error("主键无效。");
string tableName;
try
{
tableName = TableStructure.ParseModel(model).Table;
if (string.IsNullOrEmpty(tableName)) return Result<IRecord>.Error("表名无效。");
}
catch (Exception ex)
{
return new Result<IRecord>(ex);
}
var sql = sqlGetter(tableName, safetyKey);
var list = Query(database, model, sql);
var result = new Result<IRecord>();
result.Code = list.Code;
result.Exception = list.Exception;
result.Message = list.Message;
result.Entity = list.Entity.SafeFirst();
return result;
}
/// <summary>获取具有指定主键的记录。</summary>
/// <typeparam name="T">记录模型。</typeparam>
/// <param name="database">数据库对象。</param>
/// <param name="key">主键。</param>
/// <param name="sqlGetter">生成 SQL 语句的函数,传入参数为表名和主键值。</param>
public static Result<T> Get<T>(IDatabase database, string key, Func<string, string, string> sqlGetter) where T : IRecord
{
return Convert<T>(Get(database, typeof(T), key, sqlGetter));
}
/// <summary>获取主键。</summary>
/// <param name="database">数据库对象。</param>
/// <param name="model">记录模型。</param>
/// <param name="sqlGetter">生成 SQL 语句的函数,传入参数为表名。</param>
public static Result<List<string>> Keys(IDatabase database, Type model, Func<string, string> sqlGetter)
{
if (database == null) return Result<List<string>>.Error("数据库无效。");
if (model == null) return Result<List<string>>.Error("模型类型无效。");
if (sqlGetter == null) return Result<List<string>>.Error("SQL 语句获取函数无效。");
var tableStructure = null as TableStructure;
try
{
tableStructure = TableStructure.ParseModel(model);
}
catch (Exception ex)
{
return Result<List<string>>.Error(ex);
}
var tableName = tableStructure.Table;
if (string.IsNullOrEmpty(tableName)) return Result<List<string>>.Error("表名无效。");
// var keyName = null as string;
// foreach (var column in tableStructure.Columns)
// {
// if (column.Key == "Key")
// {
// keyName = column.Value.Field;
// break;
// }
// }
// if (string.IsNullOrEmpty(keyName)) return Result<List<string>>.Error("主键字段无效。");
// var sql = sqlGetter(tableName, keyName);
var sql = sqlGetter(tableName);
var query = null as IQuery;
try
{
query = database.Query(sql);
if (query == null) return Result<List<string>>.Error("查询实例无效。");
var list = new List<string>(query.Rows);
for (var r = 0; r < query.Rows; r++)
{
var key = TextUtility.SafeKey(query.Text(r));
if (string.IsNullOrEmpty(key)) continue;
list.Add(key);
}
query.Dispose();
list.Capacity = list.Count;
return new Result<List<string>>(list);
}
catch (Exception ex)
{
RuntimeUtility.Dispose(query);
return Result<List<string>>.Error(ex);
}
}
/// <summary>获取主键。</summary>
/// <typeparam name="T">记录模型。</typeparam>
/// <param name="database">数据库对象。</param>
/// <param name="sqlGetter">生成 SQL 语句的函数,传入参数为表名。</param>
public static Result<List<string>> Keys<T>(IDatabase database, Func<string, string> sqlGetter) where T : IRecord
{
return Keys(database, typeof(T), sqlGetter);
}
}
}

14
Apewer/Source/Query.cs

@ -395,10 +395,14 @@ namespace Apewer.Source
/// <summary></summary>
/// <exception cref="Exception"></exception>
public List<T> Fill<T>() where T : Record
public List<T> Fill<T>() where T : IRecord => Fill(typeof(T)) as List<T>;
/// <summary></summary>
/// <exception cref="Exception"></exception>
public List<IRecord> Fill(Type model)
{
var list = new List<T>();
var type = typeof(T);
var type = model;
var list = new List<IRecord>();
for (int r = 0; r < Rows; r++)
{
list.Capacity = Rows;
@ -486,7 +490,9 @@ namespace Apewer.Source
catch { }
}
}
list.Add((T)entity);
var iRecord = entity as IRecord;
if (iRecord != null) list.Add(iRecord);
}
return list;
}

4
Apewer/Source/Record.cs

@ -50,7 +50,7 @@ namespace Apewer.Source
public virtual string Key { get { return _key; } set { _key = TextModifier.Compact(value, KeyLength); } }
/// <summary>重置主键。</summary>
internal static void ResetKey(Record record)
internal static void ResetKey(IRecord record)
{
if (record == null) return;
record.Key = GenerateKey();
@ -59,7 +59,7 @@ namespace Apewer.Source
/// <summary>生成新主键。</summary>
public static string GenerateKey() => Guid.NewGuid().ToString().ToLower().Replace("-", "");
internal static void FixProperties(Record record)
internal static void FixProperties(IRecord record)
{
if (record == null) return;

119
Apewer/Source/SqlServer.cs

@ -383,6 +383,9 @@ namespace Apewer.Source
return list;
}
/// <summary>创建表,当表不存在时创建表,当现存表中缺少模型中属性对应的列时增加列。成功时返回空字符串,发生异常时返回异常信息。</summary>
public string Initialize<T>() where T : IRecord => Initialize(typeof(T));
/// <summary>创建表,当表不存在时创建表,当现存表中缺少模型中属性对应的列时增加列。成功时返回空字符串,发生异常时返回异常信息。</summary>
public string Initialize(Record model) => model == null ? "参数无效。" : Initialize(model);
@ -472,7 +475,7 @@ namespace Apewer.Source
}
/// <summary>插入记录。成功时候返回空字符串,发生异常时返回异常信息。</summary>
public string Insert(Record record)
public string Insert(IRecord record)
{
if (record == null) return "参数无效。";
var type = record.GetType();
@ -496,7 +499,7 @@ namespace Apewer.Source
/// <para>更新记录,实体中的 Created 和 Key 属性不被更新。成功时返回空字符串,发生异常时返回异常信息。</para>
/// <para>无法更新拥有 Independent 特性的模型。</para>
/// </summary>
public string Update(Record record)
public string Update(IRecord record)
{
if (record == null) return "参数无效。";
var type = record.GetType();
@ -520,97 +523,49 @@ namespace Apewer.Source
return execute.Error;
}
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<T> Get<T>(string key, long flag = 0) where T : Record
/// <summary>获取按指定语句查询到的所有记录。</summary>
public Result<List<IRecord>> Query(Type model, string sql) => OrmHelper.Query(this, model, sql);
/// <summary>获取按指定语句查询到的所有记录。</summary>
public Result<List<T>> Query<T>(string sql) where T : IRecord => OrmHelper.Query<T>(this, sql);
/// <summary>获取记录。</summary>
public Result<List<IRecord>> Query(Type model, long flag = 0) => OrmHelper.Query(this, model, (tn) =>
{
var k = TextUtility.SafeKey(key);
if (TextUtility.IsBlank(k) == false)
{
try
{
var type = typeof(T);
var ts = TableStructure.ParseModel(type);
var f = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" _flag=", flag.ToString(), " and");
var query = (Query)Query(TextUtility.Merge("select top 1 * from [", ts.Table, "] where", f, " _key='", k, "'; "));
var list = query.Fill<T>();
query.Dispose();
if (list.Count > 0) return new Result<T>(list[0]);
}
catch (Exception ex)
{
return new Result<T>(ex);
}
}
return new Result<T>(new Exception("参数无效。"));
}
if (flag == 0) return $"select * from [{tn}]; ";
return $"select * from [{tn}] where _flag={flag}; ";
});
/// <summary>获取记录。</summary>
public Result<List<T>> Query<T>(long flag = 0) where T : Record
public Result<List<T>> Query<T>(long flag = 0) where T : IRecord => OrmHelper.Query<T>(this, (tn) =>
{
try
{
var type = typeof(T);
var ts = TableStructure.ParseModel(type);
var f = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" where _flag=", flag.ToString());
var query = (Query)Query(TextUtility.Merge("select * from [", ts.Table, "]", f, "; "));
var list = query.Fill<T>();
query.Dispose();
return new Result<List<T>>(list);
}
catch (Exception ex)
{
return new Result<List<T>>(ex);
}
}
if (flag == 0) return $"select * from [{tn}]; ";
return $"select * from [{tn}] where _flag={flag}; ";
});
/// <summary>获取按指定语句查询到的所有记录。</summary>
public Result<List<T>> Query<T>(string sql) where T : Record
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<IRecord> Get(Type model, string key, long flag = 0) => OrmHelper.Get(this, model, key, (tn, sk) =>
{
var query = (Query)Query(sql);
if (query.Exception == null)
{
var list = query.Fill<T>();
query.Dispose();
return new Result<List<T>>(list);
}
else
{
var result = new Result<List<T>>(query.Exception);
query.Dispose();
return result;
}
}
if (flag == 0) return $"select top 1 * from [{tn}] _key='{sk}'; ";
return $"select top 1 * from [{tn}] where _key='{sk}' and _key='{sk}'; ";
});
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<T> Get<T>(string key, long flag = 0) where T : IRecord => OrmHelper.Get<T>(this, key, (tn, sk) =>
{
if (flag == 0) return $"select top 1 * from [{tn}] _key='{sk}'; ";
return $"select top 1 * from [{tn}] where _key='{sk}' and _key='{sk}'; ";
});
/// <summary>查询有效的 Key 值。</summary>
public Result<List<string>> Keys(Type model, long flag = 0)
public Result<List<string>> Keys(Type model, long flag = 0) => OrmHelper.Keys(this, model, (tn) =>
{
if (model != null)
{
try
{
var type = model;
var list = new List<string>();
var ts = TableStructure.ParseModel(type);
var f = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" where _flag=", flag.ToString());
var query = (Query)Query(TextUtility.Merge("select _key from [", ts.Table, "]", f, "; "));
for (var r = 0; r < query.Rows; r++)
{
var cell = TextUtility.Trim(query.Text(r));
if (cell.Length > 0) list.Add(cell);
}
query.Dispose();
return new Result<List<string>>(list);
}
catch (Exception ex)
{
return new Result<List<string>>(ex);
}
}
return new Result<List<string>>(new Exception("参数无效。"));
}
if (flag == 0) return $"select _key from [{tn}]; ";
return $"select _key from [{tn}] where _flag={flag}; ";
});
/// <summary>查询有效的 Key 值。</summary>
public Result<List<string>> Keys<T>(long flag = 0) where T : Record => Keys(typeof(T), flag);
public Result<List<string>> Keys<T>(long flag = 0) where T : IRecord => Keys(typeof(T), flag);
#endregion

119
Apewer/Source/Sqlite.cs

@ -428,7 +428,7 @@ namespace Apewer.Source
public string Initialize(Record model) => model == null ? "参数无效。" : Initialize(model.GetType());
/// <summary>创建表,不修改已存在表。成功时返回空字符串,发生异常时返回异常信息。</summary>
public string Initialize<T>() where T : Record => Initialize(typeof(T));
public string Initialize<T>() where T : IRecord => Initialize(typeof(T));
/// <summary>创建表,不修改已存在表。当现存表中缺少模型中属性对应的列时增加列。成功时返回空字符串,发生异常时返回异常信息。</summary>
public string Initialize(Type model)
@ -478,7 +478,7 @@ namespace Apewer.Source
}
/// <summary>插入记录。成功时候返回空字符串,发生异常时返回异常信息。</summary>
public string Insert(Record record)
public string Insert(IRecord record)
{
if (record == null) return "参数无效。";
record.FixProperties();
@ -497,7 +497,7 @@ namespace Apewer.Source
}
/// <summary>更新记录,实体中的 Created 和 Key 属性不被更新。成功时返回空字符串,发生异常时返回异常信息。</summary>
public string Update(Record record)
public string Update(IRecord record)
{
if (record == null) return "参数无效。";
record.FixProperties();
@ -516,98 +516,49 @@ namespace Apewer.Source
return execute.Error;
}
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<T> Get<T>(string key) where T : Record => Get<T>(key, 0);
/// <summary>获取按指定语句查询到的所有记录。</summary>
public Result<List<IRecord>> Query(Type model, string sql) => OrmHelper.Query(this, model, sql);
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<T> Get<T>(string key, long flag) where T : Record
{
var k = TextUtility.SafeKey(key);
if (TextUtility.IsBlank(k) == false)
{
try
{
var ts = TableStructure.ParseModel(typeof(T));
var f = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" _flag=", flag.ToString(), " and");
var query = (Query)Query(TextUtility.Merge("select * from [", ts.Table, "] where", f, " _key='", k, "' limit 1; "));
var list = query.Fill<T>();
query.Dispose();
if (list.Count > 0) return new Result<T>(list[0]);
}
catch (Exception ex)
{
return new Result<T>(ex);
}
}
return new Result<T>(new Exception("参数无效。"));
}
/// <summary>获取按指定语句查询到的所有记录。</summary>
public Result<List<T>> Query<T>(string sql) where T : IRecord => OrmHelper.Query<T>(this, sql);
/// <summary>查询多条记录。</summary>
public Result<List<T>> Query<T>() where T : Record => Query<T>(0);
public Result<List<IRecord>> Query(Type model, long flag = 0) => OrmHelper.Query(this, model, (tn) =>
{
if (flag == 0) return $"select * from [{tn}]; ";
return $"select * from [{tn}] where _flag={flag}; ";
});
/// <summary>查询多条记录。</summary>
public Result<List<T>> Query<T>(long flag) where T : Record
public Result<List<T>> Query<T>(long flag = 0) where T : IRecord => OrmHelper.Query<T>(this, (tn) =>
{
try
{
var ts = TableStructure.ParseModel(typeof(T));
var f = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" where _flag=", flag.ToString());
var query = Query(TextUtility.Merge("select * from [", ts.Table, "]", f, "; ")) as Query;
var list = query.Fill<T>();
query.Dispose();
return new Result<List<T>>(list);
}
catch (Exception ex)
{
return new Result<List<T>>(ex);
}
}
if (flag == 0) return $"select * from [{tn}]; ";
return $"select * from [{tn}] where _flag={flag}; ";
});
/// <summary>获取按指定语句查询到的所有记录。</summary>
public Result<List<T>> Query<T>(string sql) where T : Record
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<IRecord> Get(Type model, string key, long flag = 0) => OrmHelper.Get(this, model, key, (tn, sk) =>
{
using (var query = Query(sql) as Query)
{
if (query.Exception == null) return new Result<List<T>>(query.Fill<T>());
else return new Result<List<T>>(query.Exception);
}
}
/// <summary>查询所有有效的 Key 值。</summary>
public Result<List<string>> Keys<T>() where T : Record => Keys<T>(0);
/// <summary>查询所有有效的 Key 值。</summary>
public Result<List<string>> Keys<T>(long flag) where T : Record => Keys(typeof(T), flag);
if (flag == 0) return $"select * from [{tn}] where _key='{sk}' limit 1; ";
return $"select * from [{tn}] where _flag={flag} and _key='{sk}' limit 1; ";
});
/// <summary>查询所有有效的 Key 值。</summary>
public Result<List<string>> Keys(Type model) => Keys(model, 0);
/// <summary>获取具有指定 Key 的记录。</summary>
public Result<T> Get<T>(string key, long flag) where T : IRecord => OrmHelper.Get<T>(this, key, (tn, sk) =>
{
if (flag == 0) return $"select * from [{tn}] where _key='{sk}' limit 1; ";
return $"select * from [{tn}] where _flag={flag} and _key='{sk}' limit 1; ";
});
/// <summary>查询所有有效的 Key 值。</summary>
public Result<List<string>> Keys(Type model, long flag)
/// <summary>获取指定类型的主键,按 Flag 属性筛选。</summary>
public Result<List<string>> Keys(Type model, long flag = 0) => OrmHelper.Keys(this, model, (tn) =>
{
if (model != null)
{
try
{
var list = new List<string>();
var ts = TableStructure.ParseModel((Type)model);
var f = (flag == 0) ? TextUtility.EmptyString : TextUtility.Merge(" where _flag=", flag.ToString());
var query = (Query)Query(TextUtility.Merge("select _key from [", ts.Table, "]", f, "; "));
for (var r = 0; r < query.Rows; r++)
{
var cell = TextUtility.Trim(query.Text(r));
if (cell.Length > 0) list.Add(cell);
}
query.Dispose();
return new Result<List<string>>(list);
}
catch (Exception ex)
{
return new Result<List<string>>(ex);
}
}
return new Result<List<string>>(new Exception("参数无效。"));
}
if (flag == 0) return $"select _key from [{tn}] where _flag={flag}; ";
return $"select _key from [{tn}]; ";
});
/// <summary>>获取指定类型的主键,按 Flag 属性筛选。</summary>
public Result<List<string>> Keys<T>(long flag = 0) where T : IRecord => Keys(typeof(T), flag);
#endregion

4
Apewer/Source/TableStructure.cs

@ -316,7 +316,7 @@ namespace Apewer.Source
return lower;
}
private static IDataParameter GenerateDataParameter(Record entity, ColumnAttribute attribute, CreateDataParameterCallback callback)
private static IDataParameter GenerateDataParameter(IRecord entity, ColumnAttribute attribute, CreateDataParameterCallback callback)
{
var property = attribute.Property;
if (property == null) return null;
@ -371,7 +371,7 @@ namespace Apewer.Source
/// <summary>生成 IDataParameter 列表,用于 Insert 或 Update。</summary>
/// <exception cref="ArgumentNullException"></exception>
public List<IDataParameter> CreateDataParameters(Record entity, CreateDataParameterCallback callback, params string[] excluded)
public List<IDataParameter> CreateDataParameters(IRecord entity, CreateDataParameterCallback callback, params string[] excluded)
{
if (entity == null) throw new ArgumentNullException(nameof(entity));
if (callback == null) throw new ArgumentNullException(nameof(excluded));

93
Apewer/_Common.props

@ -1,5 +1,7 @@
<Project>
<!--<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />-->
<!-- 生成 -->
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@ -11,7 +13,7 @@
<!-- 程序集信息 -->
<PropertyGroup>
<Product>Apewer Libraries</Product>
<Version>6.3.5</Version>
<Version>6.3.6</Version>
</PropertyGroup>
<!-- NuGet -->
@ -25,4 +27,93 @@
<DefineConstants>DEBUG;TRACE;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<!-- .NET Standard 2.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
<AssemblyTitle>$(AssemblyName) - .NET Standard 2.1</AssemblyTitle>
<DefineConstants>NETSTD;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<!-- .NET Standard 2.0 -->
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<AssemblyTitle>$(AssemblyName) - .NET Standard 2.0</AssemblyTitle>
<DefineConstants>NETSTD;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<!-- .NET Framework 2.0 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net20'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 2.0</AssemblyTitle>
<DefineConstants>NETFX;NET20;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net20'">
<Reference Include="CustomMarshalers" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Management" />
<Reference Include="System.Security" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<!-- .NET Framework 4.0 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net40'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 4.0</AssemblyTitle>
<DefineConstants>NETFX;NET40;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net40'">
<Reference Include="CustomMarshalers" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.Core" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Security" />
<Reference Include="System.Speech" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" />
</ItemGroup>
<!-- .NET Framework 4.6.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='net461'">
<AssemblyTitle>$(AssemblyName) - .NET Framework 4.6.1</AssemblyTitle>
<DefineConstants>NETFX;NET461;NET45;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<Reference Include="CustomMarshalers" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="System.Core" />
<Reference Include="System.Configuration" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Security" />
<Reference Include="System.Speech" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" />
</ItemGroup>
<!-- .NET Core 3.1 -->
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<AssemblyTitle>$(AssemblyName) - .NET Core 3.1</AssemblyTitle>
<DefineConstants>NETCORE;HAVE_ASYNC;HAVE_BIG_INTEGER;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<!-- 引用 Microsoft.WindowsDesktop.App 时,不需要 UseWPF 和 UseWindowsForms。-->
<!--<UseWPF>true</UseWPF>-->
<!--<UseWindowsForms>true</UseWindowsForms>-->
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
</ItemGroup>
<!--<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />-->
</Project>

4
Apewer/_Extensions.cs

@ -492,10 +492,10 @@ public static class Extensions
#region Source
/// <summary>为记录的 Key 属性设置新值。</summary>
public static void ResetKey(this Record @this) => Record.ResetKey(@this);
public static void ResetKey(this IRecord @this) => Record.ResetKey(@this);
/// <summary>修补基本属性。</summary>
public static void FixProperties(this Record @this) => Record.FixProperties(@this);
public static void FixProperties(this IRecord @this) => Record.FixProperties(@this);
/// <summary></summary>
public static DateTime DateTime(this IQuery @this, int row, string column) => Query.DateTime(@this, row, column);

3
ChangeLog.md

@ -1,6 +1,9 @@

### 最新提交
### 6.3.6
- Source:增加 OrmHelper,并统一了 ORM 方法的实现。
### 6.3.5
- Source:FixProperties 不再修改 Flag。

Loading…
Cancel
Save