-1

I am trying to get a filtered list from MS Project and filter on the name by using something akin to contains so that we can return a reduced set of results to process.

projContext.Load(projContext.Projects, qp => qp.Include(qr => qr.Id, qr => qr.Name));

I seem to have exhausted all the options that I know about and trying to use contains isn't working for me.

Intellisense allows this . . . (but doesn't like it at run time)

projContext.Load(projContext.Projects, qp => qp.Include(qr => qr.Id, qr => qr.Name.Contains("myfilter")));
ilkerkaran
  • 4,214
  • 3
  • 27
  • 42
  • Welcome to Stackoverflow, please consider reframing your question with more details, by this abstract information, I think what you need is this var result = context.project.Where( x => x.columnname.contains(your search item)); – Mohammed Dawood Ansari Sep 02 '19 at 10:01

2 Answers2

1

.Include() is an EF Query extension that includes the navigation property you requesting, since Id and Name ( can't know for certain since you didn't provided your model class ) most certainly are values stored in the database you don't have to Include them on your query. If you are looking to filter by contains to minimize the result of your query simply add a to your query your filters like so :

   projContext.Projects.Where(project => project .Name.Contains("myfilter")));
Tiago Silva
  • 2,299
  • 14
  • 18
1

I dont know if i am understanding what is your difficulty but, to obtain the list of projects filtered by " name contains the 'myfilter'. Try this using (var context = new projContext()) { var projects = context.Projects.Where(p => p.Name.Contains("myfilter")).ToList(); }

https://learn.microsoft.com/en-us/ef/core/querying/related-data

Pedro Brito
  • 263
  • 1
  • 9