mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
-
This commit is contained in:
@@ -180,6 +180,8 @@ namespace OrmTest.Demo
|
||||
var between = db.Queryable<Student>().Where(it => SqlFunc.Between(it.Id, 1, 20)).ToList();
|
||||
|
||||
var getTodayList = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(it.CreateTime, DateTime.Now)).ToList();
|
||||
|
||||
var joinSql = db.Queryable("student", "s").OrderBy("id").Select("id,name").ToPageList(1, 2);
|
||||
}
|
||||
public static void Page()
|
||||
{
|
||||
|
@@ -8,6 +8,8 @@ using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Reflection;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
#region T1
|
||||
@@ -648,6 +650,10 @@ namespace SqlSugar
|
||||
var entityType = typeof(TResult);
|
||||
using (var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray()))
|
||||
{
|
||||
if (typeof(TResult) == typeof(ExpandoObject))
|
||||
{
|
||||
return this.Context.RewritableMethods.DataReaderToExpandoObjectList(dataReader) as List<TResult>;
|
||||
}
|
||||
if (entityType.IsAnonymousType() || isComplexModel)
|
||||
{
|
||||
result = this.Context.RewritableMethods.DataReaderToDynamicList<TResult>(dataReader);
|
||||
|
@@ -36,6 +36,24 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///DataReader to Dynamic List
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
/// <returns></returns>
|
||||
public List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader)
|
||||
{
|
||||
List<ExpandoObject> result = new List<ExpandoObject>();
|
||||
if (reader != null && !reader.IsClosed)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(DataReaderToExpandoObject(reader));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///DataReader to DataReaderToDictionary
|
||||
/// </summary>
|
||||
@@ -145,7 +163,7 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Serialize
|
||||
@@ -189,7 +207,7 @@ namespace SqlSugar
|
||||
var jsonString = SerializeObject(sourceObject);
|
||||
return DeserializeObject<T>(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DataTable
|
||||
@@ -208,7 +226,7 @@ namespace SqlSugar
|
||||
}
|
||||
return JsonConvert.DeserializeObject<dynamic>(JsonConvert.SerializeObject(deserializeObject));
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Cache
|
||||
@@ -230,9 +248,9 @@ namespace SqlSugar
|
||||
public void RemoveCache<T>(string key)
|
||||
{
|
||||
CacheManager<T>.GetInstance().Remove(key);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SugarDynamic
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ namespace SqlSugar
|
||||
public interface IRewritableMethods
|
||||
{
|
||||
ExpandoObject DataReaderToExpandoObject(IDataReader reader);
|
||||
List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader);
|
||||
List<T> DataReaderToDynamicList<T>(IDataReader reader);
|
||||
string SerializeObject(object value);
|
||||
T DeserializeObject<T>(string value);
|
||||
|
@@ -154,7 +154,6 @@
|
||||
<Compile Include="Realization\MySql\MySqlProvider.cs" />
|
||||
<Compile Include="Realization\SqlServer\SqlServerProvider.cs" />
|
||||
<Compile Include="Realization\SqlServer\Queryable\SqlServerQueryable.cs" />
|
||||
<Compile Include="Entities\SugarDynamic.cs" />
|
||||
<Compile Include="Entities\ConnectionConfig.cs" />
|
||||
<Compile Include="Entities\DbColumnInfo.cs" />
|
||||
<Compile Include="Entities\DbTableInfo.cs" />
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
@@ -98,9 +99,9 @@ namespace SqlSugar
|
||||
/// <summary>
|
||||
/// Lambda Query operation
|
||||
/// </summary>
|
||||
public virtual ISugarQueryable<SugarDynamic> Queryable(string tableName, string shortName)
|
||||
public virtual ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName)
|
||||
{
|
||||
var queryable = Queryable<SugarDynamic>();
|
||||
var queryable = Queryable<ExpandoObject>();
|
||||
queryable.SqlBuilder.QueryBuilder.EntityName = tableName;
|
||||
queryable.SqlBuilder.QueryBuilder.TableShortName = shortName;
|
||||
return queryable;
|
||||
|
Reference in New Issue
Block a user