forgot to add the query :-x
var query = session.CreateCriteria<TechSupportTicket>()
.SetCacheable(true)
.SetCacheMode(CacheMode.Normal)
.SetMaxResults(500); // TODO config this.\
var exTicket = new TechSupportTicket();
// WHY doesn't this work?
query.SetFetchMode(exTicket.NameOf(x =>
x.LogNotes), FetchMode.Lazy);
// add the created by groups restriction
if (createdByGroups != null)
query.Add(nhc.Restrictions.In(
exTicket.NameOf(x=>x.CreateGroupID),
createdByGroups));
// add the assigned to groups restriction
if (createdByGroups != null)
query.Add(nhc.Restrictions.In(
exTicket.NameOf(x=>x.AssignedGroupID),
assignedToGroups));
// add the OR'ed user filters.
var userDisJunc = new Disjunction();
if (createdByUser)
userDisJunc.Add(nhc.Restrictions.Eq(
exTicket.NameOf(x => x.CreateUserID),
userID));
if (assignedToUser)
userDisJunc.Add(nhc.Restrictions.Eq(
exTicket.NameOf(x =>
x.AssignedUserID),
userID));
// only if we specified.
if (createdByUser || assignedToUser)
query.Add(userDisJunc);
//exclude closed tickets
query.Add(!nhc.Restrictions.Eq(
exTicket.NameOf(x => x.StatusCode),
TechSupportStatusCode.CLOSED));
rValue = query.List<TechSupportTicket>();
and mappings ...
public TechSupportTicketMap()
{
// this doesn't override LazyLoads on collections, but it
would for Components.
// since we're expecting to have fully-hydrated entities
client-side
// (and won't be lazy-loading through RIA to NHib), we
might want to ensure Eager-Loading.
// - however eager-loading might be bad for querying...
base.Not.LazyLoad();
base.Cache.ReadWrite();
base.Id(x => x.TrackedItemID, Fields.TRACKED_ITEM_ID)
.GeneratedBy.Sequence("SEQ_TS_TT_TTID");
base.Table("TS_TROUBLE_TICKET");
base.HasMany<TechSupportLogNote>(x => x.LogNotes)
.KeyColumn(Fields.TRACKED_ITEM_ID)
.Not.LazyLoad()
.Inverse()
.Cache.ReadWrite();
}
public TechSupportLogNoteMap()
{
// commented out the Not lazy load because I thought it
was causing the Fetchmode to be ignored ..
// base.Not.LazyLoad;
base.Cache.ReadWrite();
base.Table("TS_LOGNOTES");
base.Id(x => x.ID, Fields.NOTE_ID)
.GeneratedBy.Sequence("SEQ_TS_LOGNOTES")
;
base.References(x => x.Ticket)
.Column(Fields.TRACKED_ITEM_ID)
.Not.Nullable()
;
base.Map(x => x.TrackedItemID, Fields.TRACKED_ITEM_ID)
.Not.Insert()
.Not.Update()
.Generated.Always()
;
#region map other fields
base.Map(x => x.CreateTimestamp, Fields.CREATE_TIMESTAMP);
base.Map(x => x.CreateUserID, Fields.CREATE_USERID);
base.Map(x => x.NoteText, Fields.NOTE_TEXT);
base.Map(x => x.Status, Fields.STATUS);
#endregion
}
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.