mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
add test
This commit is contained in:
parent
39558e6ecc
commit
d51aef2aa9
@ -405,6 +405,12 @@ namespace FreeSql.Tests
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
var floorSql = g.sqlite.Select<TaskBuild>().Where(a => a.OptionsEntity04 / 10000 == 121212 / 10000).ToSql();
|
||||
|
||||
var testBoolSql1 = g.sqlserver.Select<TaskBuild>().Where(a => a.OptionsEntity01).ToSql();
|
||||
var testBoolSql2 = g.sqlserver.Select<TaskBuild>().Where(a => a.Id == Guid.NewGuid() && a.OptionsEntity01).ToSql();
|
||||
|
||||
|
||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=7")
|
||||
.UseEntityPropertyNameConvert(Internal.StringConvertType.PascalCaseToUnderscoreWithLower)
|
||||
|
@ -28,13 +28,14 @@ public static partial class FreeSqlGlobalExtensions
|
||||
[typeof(uint?)] = true,
|
||||
[typeof(ulong)] = true,
|
||||
[typeof(ulong?)] = true,
|
||||
[typeof(double)] = true,
|
||||
[typeof(double?)] = true,
|
||||
[typeof(float)] = true,
|
||||
[typeof(float?)] = true,
|
||||
[typeof(decimal)] = true,
|
||||
[typeof(decimal?)] = true
|
||||
[typeof(double)] = false,
|
||||
[typeof(double?)] = false,
|
||||
[typeof(float)] = false,
|
||||
[typeof(float?)] = false,
|
||||
[typeof(decimal)] = false,
|
||||
[typeof(decimal?)] = false
|
||||
});
|
||||
public static bool IsIntegerType(this Type that) => that == null ? false : (dicIsNumberType.Value.TryGetValue(that, out var tryval) ? tryval : false);
|
||||
public static bool IsNumberType(this Type that) => that == null ? false : dicIsNumberType.Value.ContainsKey(that);
|
||||
public static bool IsNullableType(this Type that) => that?.FullName.StartsWith("System.Nullable`1[") == true;
|
||||
public static bool IsAnonymousType(this Type that) => that?.FullName.StartsWith("<>f__AnonymousType") == true;
|
||||
|
@ -387,6 +387,7 @@ namespace FreeSql.Internal
|
||||
static ConcurrentDictionary<Type, Expression> _dicFreeSqlGlobalExtensionsAsSelectExpression = new ConcurrentDictionary<Type, Expression>();
|
||||
static MethodInfo MethodDateTimeSubtractDateTime = typeof(DateTime).GetMethod("Subtract", new Type[] { typeof(DateTime) });
|
||||
static MethodInfo MethodDateTimeSubtractTimeSpan = typeof(DateTime).GetMethod("Subtract", new Type[] { typeof(TimeSpan) });
|
||||
static MethodInfo MethodMathFloor = typeof(Math).GetMethod("Floor", new Type[] { typeof(double) });
|
||||
|
||||
static string GetBoolString(string sql)
|
||||
{
|
||||
@ -489,6 +490,10 @@ namespace FreeSql.Internal
|
||||
break;
|
||||
}
|
||||
tsc.mapType = null;
|
||||
//switch(oper)
|
||||
//{
|
||||
// case "/": return ExpressionLambdaToSqlCallMath(Expression.Call(MethodMathFloor, Expression.Constant(1213.1d, typeof(double))), tsc)?.Replace("1213.1", $"{left} {oper} {right}");
|
||||
//}
|
||||
return $"{left} {oper} {right}";
|
||||
}
|
||||
public string ExpressionLambdaToSql(Expression exp, ExpTSC tsc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user