I am having some problems with a few queries using Linq to NHibernate. These queries are fairly simple for me to do in SQL but for some reason I am having problems with Linq
For example if I want to find all entities which have any of a list of tags attached like this (I have greatly simplified the code for this message):
public class Asset
{
public string name {get;set;}
public IList<Tag> Tags {get;set;}
}
class Tag
{
public string Name {get;set;}
}
var tagstrings = stringofchosentags.Split(',').ToList();
var actualtags = repository.GetAll<Tag>().Where(x => x.Name.IsAnyOf(tagstrings)).ToList();
var results = repository.GetAll<Asset>().Where(x => x.Tags. IsAnyOf(actualtags)).ToList();
I know there is no IsAnyOf function but this is what I want to achieve, but I don't know the best approach.
Any guidance would be much appreciated, any other info you can point me at for building queries from user input would be great too.
Thanks in advance.