linq-expressions Questions

4

Say I have an Expression<Func<T,object>> is it possible to dynamically change the return type based on a Type variable to be something like Expression<Func<T,int>> I have t...
Scotsman asked 9/7, 2015 at 21:38

2

Solved

I need to reuse available expression: Expression<Func<Picture, int>> selector = o => o.EntityId; And build expression for Where: Expression<Func<Picture, bool>> filte...
Resistor asked 24/4, 2020 at 15:44

2

Solved

So I've been tinkering with Linq.Expressions (and if anyone can suggest a more proper or more elegant way to do what I'm doing please feel free to chime in) and have hit a wall in trying to do some...
Kiss asked 31/8, 2017 at 13:43

2

Solved

I'm having a headache trying to convert the following linq expression. Expression<Func<T, object>> to the following linq expression... Expression<Func<T, U>> In the ...
Berserker asked 22/11, 2012 at 3:53

4

Solved

I have written some code to allow filtering of products on our website, and I am getting a pretty bad code smell. The user can select 1-* of these filters which means I need to be specific with the...
Australoid asked 14/2, 2019 at 19:3

3

Solved

How to combine several similar SELECT-expressions into a single expression? private static Expression<Func<Agency, AgencyDTO>> CombineSelectors(params Expression<Func<Agency, Ag...
Bills asked 30/5, 2011 at 21:1

4

Solved

I have this method and parameter. void SomeMethod(Expression<Func<Products, bool>> where) I call this method like this; int i = 9; SomeMethod(x=>x.Id==i) And I want it to produ...
Gnomic asked 7/12, 2018 at 20:17

3

Solved

I'm trying to build a parser of expressions to Odata, and i'm getting an error, when the field is nullable. public class UserRight { public bool? active } public void Test(){ Expression<Func...
Imidazole asked 29/5, 2018 at 17:12

2

Solved

I trying to append where predicates and my goal is to create the same expression as: Services.Where(s => s.Name == "Modules" && s.Namespace == "Namespace"); I have the following code:...
Kristianson asked 23/2, 2011 at 17:27

1

Solved

To start with, this is not the same as Why is Func<> created from Expression> slower than Func<> declared directly? and is surprisingly just the opposite of it. Additionally, all links and qu...
Promenade asked 3/5, 2018 at 7:53

1

Solved

I'm in the process of refactoring some code, attempting to make it more self-documenting. The current code has a query over an OData service which looks like this: return context.MessageLog....
Chough asked 2/3, 2018 at 17:48

1

I'm getting a "Code supposed to be unreachable" error when executing the following Linq to Sql statement. I'm using EF 6.1.3. I think this is a known bug related to filtering a navigation property....

4

ANSWER is: No, this is not a bug. The difference is in the ReflectedType. So the real question here is: Is there a way of comparing two PropertyInfo objects, for the same property, but reflected f...
Chevrette asked 7/10, 2012 at 3:8

3

Solved

I want to create an expression using the Linq Expression tree to simulate this: List<int> ids = new List<int>(); // Fill ids with data db.Where(a => ids.Contains(a.Id)); This is...
Germanophobe asked 28/8, 2013 at 15:4

1

Solved

I would like to debug a lambda that is called in an expression tree. Unfortunately, the breakpoint is never hit. Here's a full Console Program to play with: private static void Main() { var eval...
Scythe asked 15/3, 2017 at 1:41

2

Solved

I am trying to seed a development database with some test data. I have used context.People.AddOrUpdate(p => p.Id, people)); with much success. I have another table that I need to seed, in whic...

0

Looking at the documented overloads available for the Expression.Call(), method, I can find the following overloads to obtain an expression node that will perform a call to an instance method expec...
Overleap asked 20/12, 2016 at 21:40

0

Given an input of two expressions, e.g.: Expression<Func<Customer,string>> nameExpression = x=>x.Name; Expression<Func<Customer,string>> nameExpression = x=>x.MarketS...
Parsee asked 2/12, 2016 at 13:29

1

Solved

I want to create an expression like this: public class Entity { public virtual long Id { get; set; } } Entity alias = null; Expression<Func<object>> target = () => alias.Id;//hav...
Gatecrasher asked 23/11, 2016 at 12:18

3

Solved

Browsing the .NET core source code for System.Linq.Expressions, I found the following code located here: MethodInfo mi = property.GetGetMethod(true); if (mi == null) { mi = property.GetSetMethod(...
Web asked 17/8, 2016 at 21:26

1

Solved

I have implemented a basic (naive?) LINQ provider that works ok for my purposes, but there's a number of quirks I'd like to address, but I'm not sure how. For example: // performing projection wit...
Rye asked 15/6, 2016 at 20:59

1

Solved

I have an existing expression of type Expression<Func<T, object>>; it contains values like cust => cust.Name. I also have a parent class with a field of type T. I need a method that...
Graphology asked 2/6, 2016 at 21:49

3

Solved

I am using patterns mentioned here http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application And i am ...
Clock asked 15/4, 2013 at 7:19

1

Solved

I want to add dynamic expression in linq but facing issues on contains method it is working perfectly for Equal method Problem is i'm getting FilterField dynamically how to replace in query So f...
Zeeland asked 11/4, 2016 at 11:53

2

Solved

I am doing a Func -> Expression -> Func conversion. It works fine if I create the Func<>() from a method(first example below) however if I create the function using an expression tree(2nd exampl...
Anschluss asked 14/12, 2015 at 22:9

© 2022 - 2024 — McMap. All rights reserved.