mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Skip.First() Bug
This commit is contained in:
@@ -386,16 +386,20 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
QueryBuilder.OrderByValue = QueryBuilder.DefaultOrderByTemplate;
|
QueryBuilder.OrderByValue = QueryBuilder.DefaultOrderByTemplate;
|
||||||
}
|
}
|
||||||
QueryBuilder.Skip = 0;
|
if (QueryBuilder.Skip.Value > 0)
|
||||||
QueryBuilder.Take = 1;
|
|
||||||
var reval = this.ToList();
|
|
||||||
if (reval.HasValue())
|
|
||||||
{
|
{
|
||||||
return reval.FirstOrDefault();
|
QueryBuilder.Take = 1;
|
||||||
|
return this.ToList().FirstOrDefault();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return default(T);
|
QueryBuilder.Skip = 0;
|
||||||
|
QueryBuilder.Take = 1;
|
||||||
|
var reval = this.ToList();
|
||||||
|
if (reval.HasValue())
|
||||||
|
return reval.FirstOrDefault();
|
||||||
|
else
|
||||||
|
return default(T);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual T First(Expression<Func<T, bool>> expression)
|
public virtual T First(Expression<Func<T, bool>> expression)
|
||||||
@@ -1072,8 +1076,9 @@ namespace SqlSugar
|
|||||||
private void ToSqlBefore()
|
private void ToSqlBefore()
|
||||||
{
|
{
|
||||||
var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
|
var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
|
||||||
if (moreSetts != null && moreSetts.IsWithNoLockQuery&&string.IsNullOrEmpty(QueryBuilder.TableWithString)) {
|
if (moreSetts != null && moreSetts.IsWithNoLockQuery && string.IsNullOrEmpty(QueryBuilder.TableWithString))
|
||||||
this.With(SqlWith.NoLock);
|
{
|
||||||
|
this.With(SqlWith.NoLock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user