I have an AppUser object with a default workschedule as below:
Code:
[NHMA.OneToOne( 0, Name = "DefaultWorkSchedule", ClassType = typeof( DefaultWorkSchedule ), OuterJoin = OuterJoinStrategy.True, PropertyRef = "AppUser" )]
public virtual DefaultWorkSchedule DefaultWorkSchedule
{
get { return defaultWorkSchedule; }
set { defaultWorkSchedule = value; }
}
Here's the relevant class code from default workschedule:
Code:
[Serializable]
[Subclass(0, NameType = typeof(DefaultWorkSchedule), DiscriminatorValueEnumFormat = "d", DiscriminatorValueObject = ScheduleType.Default, ExtendsType = typeof(WorkSchedule))]
public class DefaultWorkSchedule : WorkSchedule
//etc..
And here's the base class work schedule info:
Code:
[Serializable]
[Class(0, NameType = typeof(WorkSchedule), Table = "WorkSched", DiscriminatorValue = "99")]
[AttributeIdentifier("ID.Column", Value = "WorkSchedID")]
[AttributeIdentifier("StartDateTime.Column", Value = "StartDateTime")]
[AttributeIdentifier("EndDateTime.Column", Value = "EndDateTime")]
//etc.
Ok, if I leave off this: OuterJoin = OuterJoinStrategy.True, it will try to run 5000 individual select statements when loading a grid of AppUsers. If add it, the sql is wrong. It generates this sql:
Code:
SELECT this_.AppUserID as AppUserID43_1_, this_.LoginName as LoginName43_1_, this_.FirstName as FirstName43_1_,
this_.LastName as LastName43_1_, this_.FullName as FullName43_1_, this_.ActiveFlag as ActiveFlag43_1_,
this_.UID as UID43_1_, this_.CUID as CUID43_1_, this_.HireDate as HireDate43_1_, this_.SeniorityRank as Seniori10_43_1_,
this_.SupervisorID as Supervi11_43_1_, this_.AgentID as AgentID43_1_, this_.PhoneNum as PhoneNum43_1_,
this_.iPager as iPager43_1_, this_.FaxNum as FaxNum43_1_, this_.EMailAddress as EMailAd16_43_1_, this_.WfaID as WfaID43_1_,
this_.SalesCode as SalesCode43_1_, this_.LocationID as LocationID43_1_, defaultwor2_.WorkSchedID as WorkSche1_16_0_,
defaultwor2_.AppUserID as AppUserID16_0_, defaultwor2_.StartDateTime as StartDat3_16_0_,
defaultwor2_.EndDateTime as EndDateT4_16_0_ FROM DaTrashCan.clairvoyant.AppUser this_
left outer join DaTrashCan.clairvoyant.WorkSched defaultwor2_ on this_.AppUserID=defaultwor2_.AppUserID
WHERE this_.ActiveFlag = 1 ORDER BY this_.FullName asc
When it should generate this:
Code:
SELECT this_.AppUserID as AppUserID43_1_, this_.LoginName as LoginName43_1_, this_.FirstName as FirstName43_1_,
this_.LastName as LastName43_1_, this_.FullName as FullName43_1_, this_.ActiveFlag as ActiveFlag43_1_,
this_.UID as UID43_1_, this_.CUID as CUID43_1_, this_.HireDate as HireDate43_1_, this_.SeniorityRank as Seniori10_43_1_,
this_.SupervisorID as Supervi11_43_1_, this_.AgentID as AgentID43_1_, this_.PhoneNum as PhoneNum43_1_,
this_.iPager as iPager43_1_, this_.FaxNum as FaxNum43_1_, this_.EMailAddress as EMailAd16_43_1_, this_.WfaID as WfaID43_1_,
this_.SalesCode as SalesCode43_1_, this_.LocationID as LocationID43_1_, defaultwor2_.WorkSchedID as WorkSche1_16_0_,
defaultwor2_.AppUserID as AppUserID16_0_, defaultwor2_.StartDateTime as StartDat3_16_0_,
defaultwor2_.EndDateTime as EndDateT4_16_0_ FROM DaTrashCan.clairvoyant.AppUser this_
left outer join DaTrashCan.clairvoyant.WorkSched defaultwor2_ on this_.AppUserID=defaultwor2_.AppUserID and defaultwor2_.DefaultFlag = 1
WHERE this_.ActiveFlag = 1 ORDER BY this_.FullName asc
Am I missing something in the mapping?