I have a class
public class Item : IItem
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual bool IsActive { get; set; }
}
public interface IItem
{
Guid Id { get; set; }
string Name { get; set; }
bool IsActive { get; set; }
}
public class ItemMap : ClassMap<Item>
{
public ItemMap()
{
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.IsActive);
}
}
In my database I have created five items. Three that have the IsActive flag set to true and two that have it set to false.
When using the Interface it returns all five items:
var q = from i in session.Linq<IItem>()
where i.IsActive == true
select i;
However, when using the concrete class it returns the proper three items:
var q = from i in session.Linq<Item>()
where i.IsActive == true
select i;
EDIT
I have would like to return an Interface, because I have read that I should return non-concrete classes. Please note that in actuality, these Linq queries are in a repository in a different project (in case this becomes a web or WPF app)