mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 04:23:47 +08:00
Synchronization code
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using static SqlSugar.QueryFilterProvider;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
@@ -9,6 +12,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
internal SqlSugarProvider Context { get; set; }
|
internal SqlSugarProvider Context { get; set; }
|
||||||
private List<SqlFilterItem> _Filters { get; set; }
|
private List<SqlFilterItem> _Filters { get; set; }
|
||||||
|
private List<SqlFilterItem> _BackUpFilters { get; set; }
|
||||||
|
|
||||||
public IFilter Add(SqlFilterItem filter)
|
public IFilter Add(SqlFilterItem filter)
|
||||||
{
|
{
|
||||||
@@ -46,5 +50,51 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
_Filters = new List<SqlFilterItem>();
|
_Filters = new List<SqlFilterItem>();
|
||||||
}
|
}
|
||||||
|
public void ClearAndBackup()
|
||||||
|
{
|
||||||
|
_BackUpFilters = _Filters;
|
||||||
|
_Filters = new List<SqlFilterItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Restore()
|
||||||
|
{
|
||||||
|
_Filters = _BackUpFilters;
|
||||||
|
if (_Filters == null)
|
||||||
|
{
|
||||||
|
_Filters = new List<SqlFilterItem>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTableFilter<T>(Expression<Func<T,bool>> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class,new()
|
||||||
|
{
|
||||||
|
var isOn = filterJoinType == FilterJoinPosition.On;
|
||||||
|
var tableFilter = new TableFilterItem<T>(expression, isOn);
|
||||||
|
this.Add(tableFilter);
|
||||||
|
}
|
||||||
|
public void AddTableFilterIF<T>(bool isAppendFilter,Expression<Func<T, bool>> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class, new()
|
||||||
|
{
|
||||||
|
if (isAppendFilter)
|
||||||
|
{
|
||||||
|
AddTableFilter(expression, filterJoinType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void AddTableFilter(Type type,Expression expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On)
|
||||||
|
{
|
||||||
|
var isOn = filterJoinType == FilterJoinPosition.On;
|
||||||
|
this.Add(new TableFilterItem<object>(type, expression, isOn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTableFilterIF(bool isAppendFilter, Type type, Expression expression, FilterJoinPosition posType = FilterJoinPosition.On)
|
||||||
|
{
|
||||||
|
if (isAppendFilter)
|
||||||
|
{
|
||||||
|
AddTableFilter(type, expression, posType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public enum FilterJoinPosition
|
||||||
|
{
|
||||||
|
On=0,
|
||||||
|
Where=1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -539,6 +539,11 @@ namespace SqlSugar
|
|||||||
FieldValue = value.ObjToStringNew(),
|
FieldValue = value.ObjToStringNew(),
|
||||||
CSharpTypeName = column.PropertyInfo.PropertyType.Name
|
CSharpTypeName = column.PropertyInfo.PropertyType.Name
|
||||||
});
|
});
|
||||||
|
if(value is Enum&&this.Context.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString!=true)
|
||||||
|
{
|
||||||
|
data.Value.FieldValue = Convert.ToInt64(value).ObjToString();
|
||||||
|
data.Value.CSharpTypeName = "int";
|
||||||
|
}
|
||||||
//if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)
|
//if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)
|
||||||
//{
|
//{
|
||||||
// data.Value.FieldValueConvertFunc = it =>
|
// data.Value.FieldValueConvertFunc = it =>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -223,7 +223,7 @@ namespace SqlSugar
|
|||||||
case SplitType.Year:
|
case SplitType.Year:
|
||||||
return Convert.ToDateTime(time.ToString("yyyy-01-01"));
|
return Convert.ToDateTime(time.ToString("yyyy-01-01"));
|
||||||
default:
|
default:
|
||||||
throw new Exception($"SplitType paramter error ");
|
throw new Exception($"SplitType parameter error ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DateTime GetMondayDate()
|
private DateTime GetMondayDate()
|
||||||
|
Reference in New Issue
Block a user