String based Dynamic Linq - Nested Where clause

c# dynamic-linq

Question

I'm doing string based Dynamic Linq and need to apply a nested where clause.

The answer here gets me half way there. However, the columns in two tables have matching ids. I need to be able to reference via an alias or other, like below:

rolesCollection
.Where("AssignedUsers.Where(AssignedUsers.TypId == rolesCollection.TypId).Any()");

Any idea how to accomplish this? I don't have the ability to pass in an object, this has to be purely a string based solution in the context of a genericized API search method. This is just an example of what I need ... I don't have the ability to join or anything via code. I'm looking for the solution in the string based portion of the example code.

1
2
11/20/2017 7:52:02 PM

Accepted Answer

The AssignedUsers object should, in this theoretical example, have an AssignedUsers_Typ collection, and you can simply reference below, without having to reference the Typ columns from both tables.

   rolesCollection.Where("AssignedUsers_Typ.Any()");

I was able to resolve my issue using this solution.

0
11/21/2017 9:34:34 PM

Popular Answer

Do you want something like that;

rolesCollection = rolesCollection.Where(x => assignedUsers.Any(t => t.TypId == x.TypId)).ToList();


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow