views:

114

answers:

1

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.

A: 

The current NHibernate.Linq project in contrib isn't really going to move forward. Mr. Strong has just finished fixing the AST parser in NHibernate trunk and will commence work on the brand new LINQ provider in a few weeks (he's stated that he is waiting on the re-linq project to move forward with some much-needed additions first).

Ben