when using createCriteria, how to specify SELECT..WHERE.. IN (value1, val2...) ?
+6
A:
See Restrictions.in:
List cats = sess.createCriteria(Cat.class)
.add( Restrictions.in( "name", new String[] { "Fritz", "Izi", "Pk" } ) )
skaffman
2009-11-30 08:51:54
A:
What if the Restrictions.in should be used on a list eg:
public class MainEntity
{
public virtual int ID { get;set;}
public virtual string Name { get;set;}
public virtual IList<SubEntity> SubEntitys { get;set;}
public MainEntity() { SubEntitys = new List<SubEntity>(); }
}
public class SubEntity
{
public virtual int ID { get;set;}
public virtual string Name { get;set;}
}
How can you make
List mainEntitys= sess.createCriteria(mainEntitys.class)
.add( Restrictions.in( "SubEntity", List<SubEntity>)
Is that an answer or a question? Are why have you posted it in C#?
skaffman
2009-12-03 08:55:48
I hope its a question, and sorry i posted it in C# but the main question was about ICriteria and not about language
2009-12-03 09:27:34