mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-25 01:14:33 +08:00
Synchronization code
This commit is contained in:
parent
f66aa80bc9
commit
79176334a2
@ -82,7 +82,7 @@ namespace SqlSugar
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dataReader == null) return result;
|
if (dataReader == null) return result;
|
||||||
while (await((DbDataReader)dataReader).ReadAsync())
|
while (await GetReadAsync(dataReader,context))
|
||||||
{
|
{
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
@ -116,6 +116,18 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task<bool> GetReadAsync(IDataReader dataReader, SqlSugarProvider context)
|
||||||
|
{
|
||||||
|
if (this.QueryBuilder?.Builder?.SupportReadToken==true&&context.Ado.CancellationToken!=null)
|
||||||
|
{
|
||||||
|
return this.QueryBuilder.Builder.GetReaderByToken(dataReader, context.Ado.CancellationToken.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ((DbDataReader)dataReader).ReadAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetOwnsOne(object addItem, bool isOwnsOne, EntityInfo entityInfo, IDataReader dataReader)
|
private void SetOwnsOne(object addItem, bool isOwnsOne, EntityInfo entityInfo, IDataReader dataReader)
|
||||||
{
|
{
|
||||||
if (isOwnsOne)
|
if (isOwnsOne)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Data.Common;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@ -28,6 +30,13 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region abstract Methods
|
#region abstract Methods
|
||||||
|
|
||||||
|
public virtual bool SupportReadToken { get; set; }
|
||||||
|
|
||||||
|
public virtual Task<bool> GetReaderByToken(IDataReader dataReader, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return ((DbDataReader)dataReader).ReadAsync();
|
||||||
|
}
|
||||||
public virtual void ChangeJsonType(SugarParameter paramter)
|
public virtual void ChangeJsonType(SugarParameter paramter)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System.Dynamic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@ -47,5 +48,9 @@ namespace SqlSugar
|
|||||||
string RemoveParentheses(string sql);
|
string RemoveParentheses(string sql);
|
||||||
string RemoveN(string sql);
|
string RemoveN(string sql);
|
||||||
void FormatSaveQueueSql(StringBuilder sqlBuilder);
|
void FormatSaveQueueSql(StringBuilder sqlBuilder);
|
||||||
|
|
||||||
|
bool SupportReadToken { get; set; }
|
||||||
|
Task<bool> GetReaderByToken(IDataReader dataReader, CancellationToken cancellationToken);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -11,6 +12,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public override string SqlTranslationLeft { get { return "["; } }
|
public override string SqlTranslationLeft { get { return "["; } }
|
||||||
public override string SqlTranslationRight { get { return "]"; } }
|
public override string SqlTranslationRight { get { return "]"; } }
|
||||||
|
public override bool SupportReadToken { get; set; } = true;
|
||||||
|
|
||||||
public override string RemoveParentheses(string sql)
|
public override string RemoveParentheses(string sql)
|
||||||
{
|
{
|
||||||
@ -31,5 +33,9 @@ namespace SqlSugar
|
|||||||
paramter.DbType = System.Data.DbType.String;
|
paramter.DbType = System.Data.DbType.String;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public override Task<bool> GetReaderByToken(System.Data.IDataReader dataReader, System.Threading.CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return((SqlDataReader)dataReader).ReadAsync(this.Context.Ado.CancellationToken.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user