In the following code, value is a string with comma separated values each of which is a type name. I want to get the entities which have been linked with any of these types or having one of these types in their description. I have written the following linq to sql servery and I am always getting 0 when there certainly entities with these types. Can you please help?
string[] allValues = value.Split(',');
var allTypes = ModelFactory.GetRepository<IRestaurantTypeRepository>().GetAllTypes();
return from ent in matchingEntities
from typeLink in ent.EntityRestaurantTypeLinks
join type in allTypes on typeLink.RestaurantTypeId equals type.RestaurantTypeId
where allValues.Contains(typeLink.RestaurantType.TypeName)
|| (
allValues.Contains(type.TypeName)
&& ent.Description.Contains(type.TypeName)
)
select ent;
EDIT
I have split the statement into two. After that the second statement became like this.
from ent in matchingEntities
where allValues.AsEnumerable().Any(va =>
ent.Description.Contains(va))
select ent;
In this, allValues is string[] type. ent.Description is string content. I just want to get the entities whose description contains any of the value from allValues. The above statement is not giving results.