使用NHibernate映射items-itemtags-tags表

时间:2022-09-15 16:43:06

Let's say I have this database design:

假设我有这个数据库设计:

Items
  Id
  Name
  Desc

ItemTags
  ItemId
  TagId

Tags
  Id
  Tag

And I want to map it to the following class

我想将它映射到下面的类

class Item
  int Id
  string Name
  string Desc
  IList<string> Tags

Please note that I don't want to declare a Tag class, I just want the Item class to have a list of strings that represent tags.

请注意,我不想声明Tag类,我只希望Item类有一个表示标记的字符串列表。

Is this possible?

这可能吗?

1 个解决方案

#1


0  

Why dont you want a Tag class?it will be strongly typed and alot easier to implement... Ref:

为什么你不想要一个Tag类呢?它会被强类型化并且很容易实现...参考:

IList< Tag> Tags;

IList 标签;

override the ToString() to write the "Tag" property if that makes it better..

覆盖ToString()以写入“Tag”属性,如果这样做更好..

#1


0  

Why dont you want a Tag class?it will be strongly typed and alot easier to implement... Ref:

为什么你不想要一个Tag类呢?它会被强类型化并且很容易实现...参考:

IList< Tag> Tags;

IList 标签;

override the ToString() to write the "Tag" property if that makes it better..

覆盖ToString()以写入“Tag”属性,如果这样做更好..