How to create mapper with conditions #149
-
Hi class Sensor
{
Guid ID,
string Name,
List< OwningOrganisation > Organizations
}
public OwningOrganisation(Guid OrganisationId, Guid? BuildingId, string Name, string? Description);
I created mapper
public SensorMapper : GridifyMapper<Sensor>
{
public SensorMapper()
{
AddMap(nameof(SensorDto.Name), p => p.Organizations.Select(x => x.Name));
AddMap(nameof(SensorDto.Description), p => p.Organizations.Select(x => x.Description));
AddMap(nameof(SensorDto.BuildingId), p => p.Organizations.Select(x => x.BuildingId));
}
} I need to create query like I there is possibility to create this query with gridify? |
Beta Was this translation helpful? Give feedback.
Answered by
alirezanet
Feb 11, 2024
Replies: 1 comment
-
Hi @Maggus85, var org = ... (some value)
var query = dataSource
.Where(q=>q.Organizations.Any(w => w.OrganizationId == org) ) // static query
.ApplyFiltering(gridifyQuery) // dynamic query
.ToList(); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Maggus85
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Maggus85,
for the static part of your query, you can use linq and combine it with gridify using one of the extension methods like
ApplyFiltering