Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
57 views

Pass ModelExpression for use in asp-for tag helper in Razor Pages [duplicate]

I have some repeated code I'd like to move to a Razor Pages code block, which contains an asp-for tag helper. That expects a ModelExpression, and I'm unsure how to pass that. @model IndexModel @{ ...
lonix's user avatar
  • 21.5k
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 ...
Kyohei Kaneko's user avatar
3 votes
2 answers
87 views

Why isn't my supplied predicate being matched when using Moq?

Given a simple type I'm testing, say interface IMyRepo { MyObj GetBy(Expression<Func<MyObj, bool> predicate); } so the standard mock setup works just fine: _repoMock.Setup(x => x.GetBy(...
oflahero's user avatar
  • 1,330
0 votes
1 answer
78 views

How to find entity types in IQueryExpressionInterceptor?

How can I find all the entity types referenced by the Expression passed to IQueryExpressionInterceptor.QueryCompilationStarting? Where in the expression tree should I look for them? I've tried a ...
Kevin Krumwiede's user avatar
2 votes
1 answer
76 views

Pattern matching with Expression<Func<T, bool>>

Consider the following code: internal static class Program { private static void Main() { object value = "Hello"; Console.WriteLine(value.Test(o => o is string)); ...
Matthew Layton's user avatar
2 votes
2 answers
87 views

Dynamically created event handler that writes ito a `ref` parameter

I want to subscribe to any event existing on a given object, where I don't know the type in advance. I'm generatig event handler at run-time using System.Linq.Expressions.Expression. The code I have (...
Tymur Gubayev's user avatar
0 votes
0 answers
32 views

The type arguments for method cannot be inferred from the usage, but explicitly defining removes benefits of intended usage [duplicate]

I'm having some trouble understanding why the type arguments can't be inferred from the usage below. While the types can clearly be inferred in Build, I'm struggling to understand why (I'm assuming) ...
Ranky's user avatar
  • 117
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 { ...
Andy Braham's user avatar
  • 10.2k
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 ...
MonstraG's user avatar
  • 383
0 votes
0 answers
178 views

Microsoft's rule engine throws an exception if the input lacks the specified property

I am using Microsoft's rule engines. The issue arises when the expression references a property that does not exist in the input object, causing the RuleExpressionParser to throw an exception. private ...
LP13's user avatar
  • 34.4k
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 ...
Michael's user avatar
  • 1,421
0 votes
0 answers
23 views

Strange ArgumentException in Expression Tree Query Statement

Note: the answer can be in either VB.NET or C#. I have no preference for this Q&A. I'm trying to distill this rather cumbersome line: Dim oSession As Session oSession = Await Me.DbContext....
InteXX's user avatar
  • 6,437
2 votes
1 answer
89 views

Compile deserialized Expression using Serialize.Linq

I'm not able to find the way how to compile the deserialized Expression using Serialize.Linq. The accepted answer in "Compile Expression at runtime Using Serialize.Linq" doesn't work (part 2 ...
rotabor's user avatar
  • 4,774
1 vote
1 answer
55 views

What is wrong with this Reflection.Emit for value conversion delegates?

Sorry for this long question but I feel I have to provide a bit more background as my issue is very specific. Bigger picture I am developing on a Unity tool to be used specifically for Embedded Linux ...
derHugo's user avatar
  • 91.4k
0 votes
1 answer
51 views

Can I reuse one Expression object for multiple lambdas building?

I want to reuse Expression instances for another Expression building like in the code below. Is it safe? Are there any pitfalls with it? using System.Linq.Expressions; class Program { static void ...
Nikita Andreev's user avatar

15 30 50 per page
1
2 3 4 5
41