Skip to content

Commit

Permalink
- 修复 时枚举转 int 再转字符串报错;#1781
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Apr 17, 2024
1 parent 26a6fe9 commit daf1fa0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions Examples/base_entity/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@ public class Student : BaseEntity2
{
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}")]
public class Class1111
Expand Down Expand Up @@ -570,9 +577,9 @@ static void Main(string[] args)
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
//.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)
//.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")
Expand Down Expand Up @@ -612,6 +619,20 @@ static void Main(string[] args)
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#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.Aop.AuditValue += (_, e) =>
Expand Down
2 changes: 1 addition & 1 deletion FreeSql/Internal/CommonExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,7 @@ public static object ExpressionGetValue(Expression exp, out bool success)
var expStackFirstMem = expStack.First() as MemberExpression;
if (expStackFirstMem.Expression?.NodeType == ExpressionType.Constant)
firstValue = (expStackFirstMem.Expression as ConstantExpression)?.Value;
else
else if (exp.IsParameter() == false)
return Expression.Lambda(exp).Compile().DynamicInvoke();
break;
case ExpressionType.Call:
Expand Down

0 comments on commit daf1fa0

Please sign in to comment.