Date Filtered Collections without Functions

Posted by madcapnmckay on Stack Overflow See other posts from Stack Overflow or by madcapnmckay
Published on 2009-06-24T11:37:37Z Indexed on 2010/03/25 20:03 UTC
Read the original article Hit count: 307

Filed under:
|
|

Hi,

I have an entity similar to the below:

public class Entity
{
    public List<DateItem> PastDates { get; set; }
    public List<DateItem> FutureDates { get; set; }
}

public class DateItem
{
    public DateTime Date { get; set; }
    /*
     * Other Properties
     * */
}

Where PastDates and FutureDates are both mapped to the same type/table. I have been trying to find a way to have the Past and Future properties mapped automagically by Nhibernate. The closest I came was where clause on the mapping as follows

HasMany(x => x.PastDates)
            .AsBag().Cascade
            .AllDeleteOrphan()
            .KeyColumnNames.Add("EventId").Where("Date < currentdate()")
            .Inverse();

Where currentdate is a UDF. I do not want to have these database specific functions if I can avoid it, mostly because i can't then test my DAL with SQLite as it doesn't support functions or stored procedures.

At the moment I am building the past and future collections using Criteria and adding to my DTO manually.

Anyone know how this could be achieved without using any UDFs?

Many thanks,

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about fluent-nhibernate