Mapping a date to a date range

Original Post Miguel Santos's Avatar

Miguel Santos

03 Jun, 2010 10:05 AM via web

Hi,
Wonder if this is possible and if can help;

public class ClassA
{
  long Id 
  DateTime FirstDay 
  DateTime LastDay 
  ...
}

public class ClassB
{
  DateTime ADate
  ClassA A
  ...
}

class ClassAMap
{
    CompositeId()
      .KeyProperty(x => x.Id, "ID")
      .KeyProperty(x => x.FirstDay, "FIRST_DAY")
      .KeyProperty(x => x.LastDay, "LAST_DAY"); 
    ...
}

The key of ClassB includes ADate and A (the reference to ClassA) but I need the resulting mapping to be such that ClassB.ADate between ClassA.FirstDay and ClassB.LastDay both in code and resulting SQL like;

from TableB b
inner join TableA a
  on b.TableA_ID = a.ID and b.ADATE between a.FIRST_DAY and a.LAST_DAY

Hope you can help as i am running out of ideas!

Many Thanks

    Reply to this discussion

    Preview Comments are parsed with Markdown. Help with syntax

    Attached Files

      You can attach files up to 10MB

      What is the opposite of bad?