All Questions
Tagged with linq-expressions linq
302 questions
0
votes
1
answer
49
views
Extract a strongly typed expression from a function expression body
I'm trying to write a "relaxed" comparison method which operates on Expressions and is used in Entity Framework. It consists of a chain of Replace() calls and ToLower() to perform an inexact ...
1
vote
1
answer
103
views
Possible to use LINQ Expression with Delegate Signature to obtain parameters?
Is it possible to obtain ParameterInfo and argument values for a delegate invocation which is inside a (compiler-generated) LambdaExpression?
For example I have defined a delegate:
public class A
{
...
2
votes
2
answers
160
views
How can I reuse the logic in a .Include.Where() call while working with Entity Framework Core in .NET?
I am writing a database query using LINQ in .NET and I want to be able to not duplicate the code I put in my Where method calls.
I want to return Blogs that have fresh Comments, and want to filter ...
0
votes
0
answers
52
views
How to Replace a MethodCall With a Lambda in Visit()
I have code that will replace an annotated property in a LINQ query with a predefined lambda. Here's an example of such a property, followed by the Visitor code that does the replacement:
public ...
2
votes
1
answer
91
views
How add MemberInitExpression into Bindings other Lambda MemberInitExpression
I have the following classes:
class Source {
public int Id { get; set; }
public string Name { get; set; }
public SourceItem Item { get; set; }
}
class SourceItem {
public Guid Id { ...
0
votes
1
answer
133
views
Adding a dynamic GroupBy expression to an IQueryable
I want to pass a dynamic GroupBy expression into an IQueryable. I'm already doing something similar with a Where clause that is working OK.
The purpose of the group by is then to allow my to extract ...
0
votes
0
answers
67
views
Using C# Expressions to build Array.All for Entity Framework
I'm building a SQL "WHERE" clause dynamically using the System.Linq.Expressions.Expression class.
There are two tables
Report and Document with relation one to many
public class Report
{
...
2
votes
1
answer
225
views
Getting MethodInfo at compile time for a non-static method
I'm working on a program that calculates expressions at runtime based on a set of inputs, then executes those remotely. This requires creating expressions dynamically that call different helper ...
0
votes
1
answer
460
views
Handling DateTimes with Linq Expression
I'm trying to create a Linq Expression to compare a date column with DateTime.Now
Here's my code
private void ProcessQueueEntries()
{
_logger.LogInformation("ProcessQueueEntries");
...
1
vote
0
answers
211
views
C# OrderBy used by Func Expression
Hi I am having problem with this expressions:
I am creating List of two expression for OrderBy(orderby(first from list).thenby(second from list)), but in some cases Recipient can be null.
List<...
0
votes
1
answer
337
views
Building Expression to search in child properies (collection) of object
I have a search setup to return matching Record objects based on criteria. It builds an Expression Tree based on the type of criteria and queries the database to return matches. Previously, it only ...
2
votes
2
answers
2k
views
SELECT result map to entity in Dynamic Linq in Entity Framework Core
I have a Linq query which is selecting 2 columns(that can be any 2 from all columns) dynamically based on some condition.I need to map the query result in to below model irrespective of selected ...
0
votes
1
answer
4k
views
Dynamic Linq in Entity Framework Core
I need to create a Linq query having Where and Select both dynamic.I am searching something like below code which will work in .net core.
var result = myQuery
.Where("Field1=\"SomeValue\&...
0
votes
1
answer
1k
views
How to pass a variable to predicate expression?
I'm creating Expression<Func<Entity, bool>> expression tree dynamically:
int id = ...;
Expression<Func<Entity, int>> keySelector = e => e.Id;
BinaryExpression equals = ...
1
vote
0
answers
1k
views
The LINQ expression could not be translated when trying to combine two expressions
Trying to combine two expressions into a single one. First expression loks following:
Expression<Func<Course, bool>> courseStatusFilter = c => c.Status == status;
second expression, ...