v0.1.4 判断 SqlServer 服务器版本,选择分页模式 row_number 或 offset fetch next;

This commit is contained in:
28810
2019-02-27 19:16:26 +08:00
parent 3ec5081d1b
commit a3720bf81e
6 changed files with 19 additions and 4 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.1.3</Version>
<Version>0.1.4</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors>
<Description>打造 .NETCore 最方便的 ORMDbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>

View File

@ -11,7 +11,9 @@ namespace FreeSql.SqlServer.Curd {
class SqlServerSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1> where T1 : class {
internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, IFreeSql _orm)
=> ToSqlStaticRowNumber(_commonUtils, _select, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, _orm);
=> (_commonUtils as SqlServerUtils).IsSelectRowNumber ?
ToSqlStaticRowNumber(_commonUtils, _select, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, _orm) :
ToSqlStaticOffsetFetchNext(_commonUtils, _select, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, _orm);
#region SqlServer 2005 row_number
internal static string ToSqlStaticRowNumber(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, IFreeSql _orm) {

View File

@ -36,6 +36,13 @@ namespace FreeSql.SqlServer {
this.DbFirst = new SqlServerDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
this.CodeFirst = new SqlServerCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
using (var conn = this.Ado.MasterPool.Get()) {
try {
(this.InternalCommonUtils as SqlServerUtils).IsSelectRowNumber = int.Parse(conn.Value.ServerVersion.Split('.')[0]) <= 10;
} catch {
}
}
}
internal CommonUtils InternalCommonUtils { get; }

View File

@ -11,6 +11,8 @@ namespace FreeSql.SqlServer {
public SqlServerUtils(IFreeSql orm) : base(orm) {
}
internal bool IsSelectRowNumber = true;
internal override DbParameter AppendParamter(List<DbParameter> _params, string parameterName, Type type, object value) {
if (string.IsNullOrEmpty(parameterName)) parameterName = $"p_{_params?.Count}";
else if (_orm.CodeFirst.IsSyncStructureToLower) parameterName = parameterName.ToLower();