Questions tagged [dynamic-linq]
Dynamic LINQ is a small library on top of the .NET framework 3.5 or later which allows to build string based query expressions. A common use case is to create LINQ queries at runtime in contrast to constructing queries at compile time.
570
questions
0
votes
1
answer
9
views
error parsing dynamic link query using Microsoft Json Rules engine
Using Microsoft Json Rules engine.
The following rule expressions parse without an issue:
"Names[0].PersonName.FirstName=="Paul""
Names.Any()
but 3. throws the following parse ...
0
votes
0
answers
88
views
Dynamic Linq custom type conversion for query
I'm trying to use dynamic Linq (System.Linq.Dynamic.Core) to query
data from MongoDB, based on a SQL-like string query I get from Excel.
This
works, but I'm trying to change the semantics of date - ...
0
votes
0
answers
32
views
How could I select each group within an IGrouping with Dynamic Linq
I am trying to select from an IQueryable ome fields then from an IGrouping the amount on each of them. but apparently it doesn't seem to work the query looks like
var selectGrouping =
"new (it....
0
votes
1
answer
92
views
Using ternary operator/conditional on select on dynamic linq
I am looking to do a linq query with Dynamic Linq library, but I am trying to select a property which is an IEnumerable<T> collection which throws an exception when calling the Sum() function in ...
1
vote
3
answers
213
views
Using the LIKE operator in Dynamic LINQ [duplicate]
Note: If you have the same problem and found this question before the "duplicated" one, be aware that the answer to that question does not work. I marked the only working solution below.
I'm ...
-1
votes
1
answer
139
views
'Parameter count mismatch' Error when trying to insert List<dynamic> to Excel using closedXml InsertData
I am trying to export dynamic list items to excel using ClosedXML. The goal is to allow end user to select the columns to be exported. Since the columns are dynamic, I use.ToDynamicListAsync() of ...
1
vote
0
answers
60
views
EF 6 Core IEnumerable<T> Projection to Dynamic Object
I have been struggling on this for a day now and I can't figure out how to do this:
I have an IEnumerable (Query generated in steps) that I'm taking in as a param (right after the where clause).
Base ...
0
votes
1
answer
40
views
Dynamic Linq to Select records with null value
Culture is dynamically selected, so that "Name_culture" param could be "name_en" or "name_it" and so on. That said, once culture is selected, all records where related ...
0
votes
1
answer
244
views
Can you get an IQueryable and its results from its string representation?
I've started a Blazor Web Assembly Project that makes use of Radzen components. I'm trying to create a search through my API, and I would like to use a combination of their DataGrid and new DataFilter ...
2
votes
1
answer
75
views
Dynamic LINQ with Skip and Take causes Exception: Unknown LINQ expression of type 'Dynamic'
I'm building a report builder/runner using System.Linq.Dynamic.Core (1.2.20) in an ASP.NET MVC (5.2.9) app and I mostly have it working, except for one annoying issue. I can't get Skip and Take to ...
1
vote
1
answer
156
views
Dynamic Linq - how do you sort a collection by Enum property alphabetically?
I have a collection of entities.
One of the properties is an enumeration.
How can I sort the collection alphabetically by its enum name instead of value?
In LINQ it would look like this:
var a = ...
0
votes
2
answers
75
views
Dynamic LINQ Any() is Returning Invalid Results
Problem Setup
I'm attempting to implement validation rules into my app using the System.Linq.Dynamic.Core package, but I'm running into weird behavior. My idea is to have the ability to create and ...
0
votes
1
answer
137
views
How to dynamically query IQueryable array by each property using reflection?
I have search method with gets as parameter some DTO and make where filtering dynamically by DTO properties. The problem I get when using reflection is that I should explicitly cast to a property type ...
0
votes
1
answer
548
views
System.Linq.Dynamic.ParseException: 'expression expected'
I get this error when I'm doing the datatable serverside processing.
The error is thrown when I call this method with Ajax.
I think the problem is server-side coding and I didn't get the problem maybe ...
-1
votes
1
answer
50
views
Unused dynamic SQL removal
Supose I have the following classes:
public class Person
{
public int Id {get; set;}
public string Name {get; set;}
public IEnumerable<Address> Address {get; set;}
}
public class Address
{...
0
votes
1
answer
347
views
Inability to use "MaxBy" on "Where" clauses with EFCore + MySQL
My database has the following structure:
public class Ticket
{
public int Id { get; set; }
public List<History> Histories { get; set; }
}
public class Employee
{
public int Id { get;...
1
vote
3
answers
283
views
What is the correct way to use computed properties with Dynamic LINQ?
I have these models.
public class Ticket
{
public int Id {get;set;}
public List<History> History {get;set;}
}
public class History
{
public Employee Employee {get;set;}
public ...
1
vote
1
answer
113
views
Dynamic linq not correctly apply on list of DynamicClass
I'm trying to use dynamic linq over DynamicClass list. From external source I'm getting field.Name = "firstName" and field.Value = "firstValue".
var dynamicIndexes = new List<...
1
vote
1
answer
68
views
Select parent but order by certain child with dynamic linq
I'am trying to write following in Dynamic-linq. I have following statement in ordinary linq
var result = DBContext.Report
.Include(h => h.ReportRoleMemberships)
.Join(DBContext....
0
votes
1
answer
266
views
System.Linq.Dynamic.Core.Exceptions.ParseException: 'No property or field 'Product' exists in type 'Product''
This is my Product entity:
public class Product : IEntity<Guid>
{
public Guid Id { get; set; }
public string? Name { get; set; }
public Inventory? ProductInventory { ...
-1
votes
2
answers
118
views
How to create a LINQ group by query with dynamic columns?
I want to group by a datatable by the columns which are present in a List. Moreover I want to sum a column using group by result.
How to create a dynamic linq query for this?
0
votes
1
answer
114
views
Dynamic Linq to evaluate a JObject
I'm using the Dynamic Linq library. There are some expressions which are not evaluating, and I believe it's because the object gets deserialized to a JObject.
I have the following test which is ...
1
vote
2
answers
828
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
420
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
601
views
how to add dynamic properties to entities at run time
I'm using Dynamic Linq to select a few fields from a database query
Lets say I have following class
Class User
Property LastName as string
Property Email as string
End Class
But I want to call the ...
0
votes
2
answers
559
views
Dynamic Linq in abp.io 5.1 using EF Core in .NET 6 framework
I use a generated abp.io 5.1 application which uses EF Core accessing a MySQL database, running on the .NET 6 framework.
I already read those docs :
https://docs.abp.io/en/abp/latest/Entity-Framework-...
1
vote
1
answer
590
views
System.Linq.Dynamic.Core.Exceptions.ParseException: 'Type 'System.IO.DirectoryInfo' not found'
I'm trying to parse a dynamic expression and get the error System.Linq.Dynamic.Core.Exceptions.ParseException: 'Type 'System.IO.DirectoryInfo' not found'
I'm using System.Linq.Dynamic.Core 1.2.12 in ....
0
votes
1
answer
271
views
Dynamic LINQ or multiple columns
I'm using DynamicLinq on my Net Core Web API. The main purpose is to select data based on multiple columns filtered by OR
This is the Model
public class Car
{
public int Id { get; set; }
...
0
votes
1
answer
187
views
DynamicLinq : how to use custom class method without class name to ParseLambda
I'm using DynamicExpressionParser.ParseLambda(ParsingConfig, ....)
which excepts ParsingConfig where we can specify custom class to use its method in expression, which can be parsed as valid ...
0
votes
1
answer
182
views
Error on Selecting nested List of Objects with dynamic linq
I'm trying to write a typed dynamic projection method using dynamic linq in c#.
I only want to select certain fields of my Dtos even in nested Collections like Useraddresses from my example. The ...
1
vote
2
answers
276
views
Selecting empty string with Dynamic LINQ
Pretty simple requirement: I need to select a named column with an empty string in Dynamic LINQ. Something along the lines of:
myQuery.Select("new(Col1, Col2, '' AS Col3)");
This doesn't ...
0
votes
0
answers
96
views
Dynamically join from view to key-value table in Entity Framework 6
In my project, I have one regular table in form of a view. Let's call it BaseView. Another table KeyValueTable contains three columns: ID_BaseView, Key and Value.
Joining them together in SQL is quite ...
0
votes
1
answer
232
views
Add static column to Dynamic LINQ query
In my project, I'm using Dynaic LINQ (https://dynamic-linq.net/) to select data from a database. Here's my current select code:
List<dynamic> clientData = await clientDataset
.Select($"...
1
vote
1
answer
193
views
Linq.Dynamic.Core failing for DateTime condition
I am trying to build a dynamic query using Linq.Dynamic.Core. So the idea is that the query needs to execute based on various conditions like Contains,AND,OR. All of those are working fine but greater ...
1
vote
1
answer
331
views
Linq Dynamic Query Issue - Operator '&&' incompatible with operand types 'String' and 'Boolean'
I have a method which generates from my query.
It looks like this:
private static string PrepareWhereClause(string[] columns)
{
var query = $"({string.Join(" OR ", columns?.Select(c ...
0
votes
3
answers
287
views
Dynamically Entering "select" by a string in LINQ Query
List<int> list = new List<int> { 1, 2, 4, 5, 6, 7 };
string selectQuery = "x";
var result = from x in list
where x > 3
...
0
votes
0
answers
167
views
Using Dynamic Linq to select a simple List<long> from list of models where the selected field is dynamic
I'm trying to create a generic function within my application, and the one thing holding me up is a lambda expression that relies on knowing the object primary key.
eg. I'm extracing a list of ...
1
vote
1
answer
475
views
How to create dynamic LINQ Expression with multiple binary expression conditions and a contains condition
I want to create a dynamic LINQ Expression for this kind of query
people.Where(x => x.Name="Some_Name" && x.Age>60 && x.ChildIds.Contains("Some_Id"));
What I ...
0
votes
1
answer
166
views
Asp.net core - Entity Framework core - add additional data to a view object while keeping it a Queryable
[EnableQuery]
public ActionResult<IQueryable<OurView>> GetInteractionRecordings(int pageNumber)
{
IQueryable<OurView> ourViews = _dbContext.OurView
.Skip((...
1
vote
1
answer
108
views
Entity Framework dynamic linq where from generic source with dynamic where clause
I am trying to query Entity Framework where clause statement with generic type when table name is not known.
I am trying to use dynamic linq:
public static IEnumerable<T> wherePost<T>(this ...
0
votes
1
answer
367
views
Dynamic Linq nested Select on collection property
We are using GraphQL Dotnet in a dotnet core 5.0 API.
We have a relational data structure like this
Organisation --> (Zero or many) Employers --> (Zero or many) Departments.
In an attempt to ...
0
votes
2
answers
191
views
Left join a queryable on multiple property on a non-generic queryable using Dynamic.Linq
I have 2 queryables containing the following entities:
class Entity
{
int Id { get;set; }
}
class ExtraField
{
int EntityId { get;set; }
string Key { get;set; }
string Value {get;set; }
}...
0
votes
0
answers
62
views
Dynamically adding left joins/columns in LINQ
I have the following two tables,
CustomerID
1
2
3
CustomerID
RelID
Value
1
1
abc
2
2
def
3
1
ghi
1
3
ijk
2
4
lmn
I'm trying to get the following output, my requirement is that the RelID ...
1
vote
1
answer
408
views
Dynamic Linq Order By Parent and Child Collection
I'm using System.Linq.Dynamic.
Given this parent - child (collection) model below, is it possible use OrderBy Client based on createdDate property passing the Id of the specific Address to sort with? ...
1
vote
2
answers
463
views
How to select and count base on a condition of another field using dynamic linq core
I'm using Entity Framework and Dynamic Linq Core to perform some dynamic queries at run time. I have a question on how to write dynamic linq statements to output columns of counts where each column is ...
0
votes
1
answer
645
views
Dynamic Linq Expression Query Nested List Object
Is it possible to dynamically build an IQueryable/Linq Expression with filtering criteria based on a NESTED/Child List Object's Property.
I have not included all code here - particularly the code ...
0
votes
1
answer
106
views
Dynamic Linq with IN List
I am using EF Dynamic Linq library to construct dynamic queries based on user input.
I was able to set the where clause like this to search for User Roles = 1:
var users = await _db.Users....
0
votes
1
answer
470
views
Dynamically update table using Dynamic LINQ
I have a list of column names and I want to dynamically update table and set all the rows for those columns to NULL. The current code is using if logic and it need to keep updating when list of ...
0
votes
1
answer
32
views
How to construct having clause in Dynamic LINQ
I want to find duplicate rows in a table given the list of columns. I am using Dynamic LINQ to group by columns and then want to check if there are any records having count greater than 1.
The group ...
0
votes
1
answer
157
views
How to escape string for dynamic linq where clause
I am using Dynamic LINQ to find the records using dynamic where clause. I have instance of Person class
public class Person
{
public string Name {get;set;}
public int Age {get;set;}
public ...