Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Using Linq.Dynamic to filter nullable string Entity

$
0
0

I'm building filter strings in this fashion:

filter = "" & column.DataPropertyName & ".ToLower().Contains(""" & value.ToLower & """)"

I'm filtering a DataGridView with the results, like so:

m_WorkSelectionItems.Where(filter).ToList

This works fine if the column.DataPropertyName happens to be a required field. A null reference exception is of course thrown when it is not and when the property's value is null.

Does anyone know of a way I can query nullable string entity properties with a one-liner for things such as "contains", "starts with", "ends with", etc?


Viewing all articles
Browse latest Browse all 12583

Trending Articles