Comments (3)
I see. Member methods on models are not supported. Properties on models are, though.
public class MyModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
[InjectLambda]
public string FullName => FullNameExpr.Compile().Invoke(this);
public static Expression<Func<MyModel, string>> FullNameExpr => m => $"{m.FirstName} {m.LastName}";
}
from nein-linq.
A member method shouldn't be static.
from nein-linq.
Sorry that was a typo while I was trying to work around the issue. The error is still there with a non-static member method.
Here's a more complete demo I've tested in LinqPad, it gives the above error.
using NeinLinq;
void Main()
{
var result = Users
.ToEntityInjectable()
.Select(i => new MyModel {
FirstName = i.FirstName,
LastName = i.LastName
})
.OrderBy(m => m.GetFullname())
.Take(1)
.ToList();
}
public class MyModel
{
public string FirstName {get;set;}
public string LastName {get;set;}
[InjectLambda]
public string GetFullname() {
return GetFullnameExpr.Compile().Invoke(this);
}
public static Expression<Func<MyModel, string>> GetFullnameExpr => (m) => $"{m.FirstName} {m.LastName}";
}
from nein-linq.
Related Issues (20)
- DynamicQuery.CreatePredicate doesn't work with Enums HOT 4
- Query tags are stripped away HOT 3
- Is it possible to store the result of an expression in a property? HOT 4
- Readonly CachedExpressions HOT 1
- Documentation: What does calling WithLambdaInjection() on DbContext options do? HOT 2
- Support For Entity Framework Core 6 HOT 18
- Doc bug HOT 1
- How about an implicit cast to `CachedExpression<X>` from `Expression<X>`? HOT 5
- Property vs method issue HOT 4
- ToInjectable vs ToEntityInjectable HOT 4
- Is `FirstOrDefaultAsync` supported HOT 1
- Q: would this work with source generators? HOT 2
- [Question/Feature Request] Overwrite member/property mapping HOT 1
- [Help] Translating from LinqKit Invoke + Expand to NeinLinq HOT 1
- Issue with NeinLinq.EntityFramework, Linq.Count() method HOT 6
- Issue with Moq HOT 1
- Cannot get the SQL query generated HOT 3
- Implement IDbAsyncQueryProvider HOT 1
- Is IQueryable result supported? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nein-linq.