Tôi đã tạo biểu thức mà tôi đang sử dụng để sắp xếp hoạt động tốt, cho đến khi tôi đạt được trường DateTime
, nơi tôi nhận được lỗi sau (trên dòng thứ hai):Không thể sử dụng cụm từ 'System.DateTime' cho loại trả về 'System.Object'
Biểu hiện của loại 'System.DateTime' không thể được sử dụng cho các kiểu trả về 'System.Object'
Dưới đây là mã của tôi:
ParameterExpression param = Expression.Parameter(typeof(MyEntity), "x");
Expression<Func<MyEntity, object>> sortExpression =
Expression.Lambda<Func<AMyEntity, object>>(
Expression.Property(param, sortKey), param);
Có ai giúp được gì không?
thể trùng lặp của [Biểu thức loại 'System.Int32' không thể được sử dụng cho kiểu trả về 'System.Object'] (http://stackoverflow.com/questions/2200209/expression-of-type-system-int32-cannot-be-used- for-return-type-system-object) – nawfal