Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Problem With Dynamic Linq Query

$
0
0

I'm querying a sharepoint list based on filters.  This works great when I was passing in up to 3 filters.  However, when I add a fourth filter I get some strange results.  If I filter on only the fourth filter it works fine.  If I choose one of the other 3 along with the fourth filter it ignores the fourth filter, but the other 3 still work.  The filter I just added is ShowClinicProviders.  I added it at the top of my code in hopes the following queries would work with a smaller list.  However, I've tried it at both the top and bottom of the code, but it doesn't work either place:

if (filters.ShowClinicProviders) // The 4th filter
{
	var clinicToFilterBy = clinicItems.FirstOrDefault(a => a.ID.ToString() == filters.ProvidersClinicID);
	if (clinicToFilterBy != null)
	{
		items = items.Where(a => a["PrimaryClinic"].ToString() == clinicToFilterBy["Clinic"].ToString());
	}
}
if (!string.IsNullOrEmpty(filters.AreaOfPractice))
{
	items = items.Where(a => a["PrimarySpecialty"].ToString() == filters.AreaOfPractice);

}
if (!string.IsNullOrEmpty(filters.Gender))
{
	items = items.Where(a => a["ProviderGender"].ToString() == filters.Gender);
}

if (!string.IsNullOrEmpty(filters.Language))
{
	items = items.Where(a => a["LanguageSpoken"].ToString().Contains(filters.Language));
}


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>