Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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 { ...
Dongdong's user avatar
  • 2,528
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....
Ivan Debono's user avatar
  • 1,016
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 ...
Hossein POURAKBAR's user avatar
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() ...
Rico Strydom's user avatar
-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 }, ...
mkedwards's user avatar
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 = "...
Diego Perez's user avatar
  • 2,946
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 ...
Patrick Shaffer -State Police-'s user avatar
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 ...
Hosein Ghasemi's user avatar
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 ...
Diego Perez's user avatar
  • 2,946
-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 ...
michael's user avatar
  • 35
-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 ...
YaSecu's user avatar
  • 95
-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(...
Benehmb's user avatar
  • 15
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; } ...
Matthias Burger's user avatar
-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 ...
Ugur Catak's user avatar
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(&...
styx's user avatar
  • 1,935

15 30 50 per page
1
2 3 4 5
254