开发者

NHibernate mapping message logic

开发者 https://www.devze.com 2023-04-05 17:37 出处:网络
I made some classes that represents my messages logic: Message - representation of THE message :) MessageBoxBase - base class for all 3 kind of messagebox

I made some classes that represents my messages logic:

  • Message - representation of THE message :)
  • MessageBoxBase - base class for all 3 kind of messagebox

  • MessageInbox - represe开发者_如何学JAVAnting inbox

  • MessageOutbox - representing outbox
  • MessageCustombox - user defined message box
  • MessageBoxItem - message item in any messagebox with such data as IsReaded etc.
  • MessageBoxCollection - Collection of messageboxes - Inbox, Outbox and List of CustomBoxes - only that 3 properties.

Finally in my agregate root User have MessageboxCollection, and I can use it somewhat like that:

myUser.MessageBoxes.Inbox.Add(...)
myUser.MessageBoxes.Outbox.Items....

NHibernate mapping message logic

I dont have any DB structure right now and I'm open on sugestion, but I was thinking about something like that:

  • MessageInInbox - UserId,MessageId, IsReaded etc.
  • MessageInOutBox - Same as in Inbox
  • MessageInCustomBox - UserId,MessageId, CustomBoxId and so on
  • CustomBox - BoxId, UserId, BoxName etc.
  • Message - plain message row, subject, content, author etc.

One I'm sure is that I don't want to create in DB row for each Inbox/Outbox for each user like it is in CustomBox case (something like unnecessary dictionary for inboxes and outboxes per user).

And in that point I have a problem - how the hell to map that ? :)

Have any suggestions? Maybe my domain is crappy? I'm waiting for yours response :)


There is a more simple solution that is that you only have two database tables called messages and boxes.

Messages - (Id, IsRead, Subject, Message, Sender, UserId, BoxId)

Boxes - (Id, Name, UserId)

This solution now allows a user to have several custom boxes and he should always have the defaults created for him. And the Object model can be User has a list of Boxes and each box has a list of messages.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号