score:3

Accepted answer

if you know t will be of type ilookup you need to put a constraint on it like such:

public interface ilookup
{
    int id { get; set; }
    string fr { get; set; }
    string nl { get; set; }
    string en { get; set; }
    bool isactive { get; set; }
}

public class lookupa : ilookup
{

}
public class lookupb : ilookup
{

}

public interface ilookuprepository<t>
{
    ilist<t> getlist();
}


public class lookuprepository<t> : ilookuprepository<t> where t : ilookup
{
    public ilist<t> getlist()
    {
        list<t> list = session.query<t>().where(y => y.isactive).tolist<t>();
        return list;
    }       
}

score:0

you should be able to leverage generic constraints to help you out.

first, change your interface definition:

public interface ilookuprepository<t> where t : ilookup
//                                    ^^^^^^^^^^^^^^^^^

second, change your class definition to match the constraints:

public class lookuprepository<t> : ilookuprepository<t> where t : ilookup
//                                                      ^^^^^^^^^^^^^^^^^

the constraint will require the generic type parameter to implement ilookup. this will let you use the interface members in your getlist method.


Related Query

More Query from same tag