- 修复 时枚举转 int 再转字符串报错;#1781

This commit is contained in:
2881099 2024-04-17 17:56:56 +08:00
parent 26a6fe9c46
commit daf1fa0629
2 changed files with 24 additions and 3 deletions

View File

@ -490,6 +490,13 @@ namespace base_entity
{ {
public string Name { get; set; } public string Name { get; set; }
} }
public record UserDto1(Guid Id, string Username, string GroupName);
public class UserDto2
{
public Guid Id { get; set; }
public string Username { get; set; }
public string GroupName { get; set; }
}
[Table(Name = "class_{0}")] [Table(Name = "class_{0}")]
public class Class1111 public class Class1111
@ -570,9 +577,9 @@ namespace base_entity
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5") //.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
//.UseQuoteSqlName(false) //.UseQuoteSqlName(false)
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true") .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true") //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
//.UseAdoConnectionPool(false) //.UseAdoConnectionPool(false)
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2") //.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2") ////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
@ -612,6 +619,20 @@ namespace base_entity
BaseEntity.Initialization(fsql, () => _asyncUow.Value); BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#endregion #endregion
var enumToString = fsql.Select<JoinTest01>().First(s => new
{
State = ((int)s.JoinTest01Enum2).ToString()
});
var userdto1s = fsql.Select<User1>().Limit(10).ToList<UserDto1>();
var userdto11s = fsql.Select<User1>().Limit(10).ToList(a => new UserDto1(a.Id, a.Username, null));
var userdto2s = fsql.Select<User1>().Limit(10).ToList<UserDto2>();
var userdto1s2 = fsql.Select<User1, UserGroup>().InnerJoin((a, b) => a.GroupId == b.Id).Limit(10).ToList<UserDto1>();
var userdto11s2 = fsql.Select<User1, UserGroup>().InnerJoin((a, b) => a.GroupId == b.Id).Limit(10).ToList((a, b) => new UserDto1(a.Id, a.Username, b.GroupName));
var userdto2s2 = fsql.Select<User1, UserGroup>().InnerJoin((a, b) => a.GroupId == b.Id).Limit(10).ToList<UserDto2>();
fsql.Select<User1>().Where(a => a.Id == new Guid("xxx")).ToList(a => new Guid("zzz")); fsql.Select<User1>().Where(a => a.Id == new Guid("xxx")).ToList(a => new Guid("zzz"));
fsql.Aop.AuditValue += (_, e) => fsql.Aop.AuditValue += (_, e) =>

View File

@ -2271,7 +2271,7 @@ namespace FreeSql.Internal
var expStackFirstMem = expStack.First() as MemberExpression; var expStackFirstMem = expStack.First() as MemberExpression;
if (expStackFirstMem.Expression?.NodeType == ExpressionType.Constant) if (expStackFirstMem.Expression?.NodeType == ExpressionType.Constant)
firstValue = (expStackFirstMem.Expression as ConstantExpression)?.Value; firstValue = (expStackFirstMem.Expression as ConstantExpression)?.Value;
else else if (exp.IsParameter() == false)
return Expression.Lambda(exp).Compile().DynamicInvoke(); return Expression.Lambda(exp).Compile().DynamicInvoke();
break; break;
case ExpressionType.Call: case ExpressionType.Call: