sasha
sasha

Reputation: 11

how to make a selection on any field from db

I have an application on wpf, c#, entity core: db mssqlsrv there Id, Name, Organization, Phone number from the database are displayed.

How can I provide an opportunity for a user to export data by any combination of fields with linq requests.

For instance: by name and organization or name and phone

I’ve been sitting for 2 days and don’t know how to do it!

Upvotes: 1

Views: 30

Answers (1)

Ricardo Peres
Ricardo Peres

Reputation: 14535

A possible solution may come from dynamic LINQ. Package System.Linq.Dynamic, available on NuGet, allows you to query LINQ style, but with a string, something like this:

ctx.People.Select("new(Name, Phone)").ToList();

It will then be just a matter of building this string dynamically.

Upvotes: 1

Related Questions