All Questions
3,807 questions
0
votes
2
answers
65
views
EF Core Fluent API to get inheritance properties
How to use EF Core Fluent API to get inheritance properties?
I have a base class and 2 inherited children classes:
class BaseClass
{
public string Name { get; set; }
}
class Child1 : BaseClass
{
...
0
votes
0
answers
77
views
How to convert a Func to an expression? [duplicate]
I have the following:
public Func<MyObj, bool> GetFilter(Status status) => status switch
{
Status.Active => x => x.Status == Status.Active && x.ValidFrom <= DateTime....
0
votes
3
answers
83
views
C# Expression to create selector using list of column names to produce new object
I have a list of available database column names as "id, age, location, etc."
I need to create an expression to use it in a EF linq selector like this but in a dynamic way. My user if free ...
2
votes
1
answer
80
views
'Failed to compare two elements in the array' when Order is done
I am getting an output from a DataTable for certain columns that have been defined in a string array: string[] columnsToBeUnique;
var ordered = dataTable1
.AsEnumerable()
...
-1
votes
1
answer
84
views
ParseLambda throws exception due to use of enum value after .NET upgrade
I recently upgraded a project from .NET 6 to .NET 8 which has code that makes a call to DynamicExpressionParser.ParseLambda(..):
var e = DynamicExpressionParser.ParseLambda(new[] { q, t, s, d, st }, ...
1
vote
2
answers
162
views
Shortest way to set a property after FirstOrDefault
Given request.Order type is ColumnName[]. I'm trying to write a one line piece of code equivalent to this incorrect code:
request.Order.FirstOrDefault(x => x.Name == "From").Name = "...
0
votes
0
answers
68
views
How can I create a parameter expression to be used in a func<EndpointAddress> expression with a predefined value?
I am trying to build a Dictionary(Of Type, Func(Of ServiceModel.EndpointAddress)). The func represents a method which takes in a single string parameter which is the service url and returns a ...
0
votes
1
answer
71
views
How to generate a lambda expression from this T-SQL code
I have SQL code like this:
select *
from [groups]
where Id in (select GroupId from groupUsers where UserId = @UserId)
I want to generate a lambda code that returns the result exactly like the above ...
0
votes
1
answer
78
views
C# LinQ: Filter object[] with elements containing a string (or part of it) from a string[]
I have a "Licenses" query which returns a Licenses[] object as follows:
var licenses = await _licenseRepository.SearchAsync(ct); //=> CT = CancellationToken
and a request filter which ...
-1
votes
1
answer
82
views
LINQ query where clause in list
I am trying to limit the data returned via a repository using the where clause based on a list of values.
I have a PurchaseOrders entity where I want to return all purchase orders that have an ...
-2
votes
1
answer
96
views
How to convert this Linq to lambda expression (Introducing the online converter) [closed]
Do you know any software or online web application or a tool in Visual Studio that can do this conversion?
And please someone help me, I can't convert this complex (to Linq Like This : From x in ...
-1
votes
1
answer
128
views
C# Linq All in Where condition
I had the following LinqExpression:
var results = _localDatabase.Table<ArticleData>()
.Where(article => article.ArticleName!.ToLower().Contains(searchQuery.ToLower(...
0
votes
0
answers
40
views
Assigning the result of a MethodInfo to a Property to work with Entity Framework
My target is to do a more dynamic and object-oriented entity-framework database-request.
So I wrote a class like this:
class Target
{
[MapFrom(nameof(GetSum))]
public int Sum { get; set; }
...
-1
votes
1
answer
103
views
OrderBy with lambda?
I have following function to generate a table shown in the output screenshot. I want to modify this function to get desired output shown below but I am not very familiar with C#. If I pass years array ...
0
votes
1
answer
88
views
Expression.Call on array with a custom function
I have a list of items, I want ,via expression, to filter out the items using my own custom function.
Something like this
return Items.Where(Foo)
private static bool Foo(Item item) { item.Name.Equals(&...