Reverse Filtering using link
Hi All,
I do an initial linq statement that in this scenario :
Code:
var locationBuilding = from location in locationBuildings.LocationBuildings select location;
That returns a set of 11 address's
Later, I attempt to filter to obtain a single address from this set using :
Code:
locationBuilding = from location in locationBuildings.LocationBuildings where location.LocationName.Contains(Row["RISKADDRESS"].ToString()) select location;
In general this gives me the results I want. However, on occassions I need to reverse this search.
i.e.
my Row["RiskAddress"] contains the value: 32 my street, my town,
but my set that I'm filtering on holds a value: 32 my street, my town
So of course my filter returns 0 records because of the trailing comma, so in cases were the returning count is 0 I want to say return me the address from the list that is like Row["RiskAddress"].
Re: Reverse Filtering using link
Should you maybe be doing this:
Code:
where location.LocationName.Contains(Row["RISKADDRESS"].ToString())
the other way around? Or maybe you could include both, i.e. where A contains B or B contains A.
Re: Reverse Filtering using link
That's what I'm currently doing, I want the reverse of it.
because my Row["RISKADDRESS"] holds an extra comma on the end the contains isn't returning the address line from the list. So I want were RISKADDRESS contains 1 of the values from the list return the item in the list as opposed to where an item in the list contains RISKADDRESS.
Re: Reverse Filtering using link
So just switch them around. You've got A contains B. Make it B contains A and you're done.