LLBLGEN 相关数组未填充到实体中
我正在与 LLBLGEN 作斗争,我猜一般是 ORM 。 我已经创建了一个实体,让我们使用图书馆示例来解释:
我想显示一本书对象并返回已借出该书的用户列表。 所以我需要返回包含用户列表的图书对象。
DTO Book::
int bookId,
string bookName
另外,我希望与我的书一起归还已借出该书的用户集合:
List<user> Loans
贷款表可能如下所示:
int id
int userid
int bookid
目前我的贷款实体已创建此:
DTO Loans
int id
User user // user entity
Book book // book entity
我正在努力了解此示例在 llblgen 中的工作方式。任何人都可以协助指导或为我提供教程吗? 目前,当我用与一本书相关的新借阅来更新我的模型书时,我收到了 stackoverflow 错误。我认为这在尝试更新我的 Book 对象时会创建某种循环。
谢谢
i'm struggling with LLBLGEN and i guess ORM's in general.
i have created an entity, lets use a library example to explain:
i want to display a book object and also return a list of users who have loaned the book.
so i need to return the book object which contains a list of users.
DTO Book::
int bookId,
string bookName
additionally i wish to return with my book a collection of users who have loaned the book:
List<user> Loans
loans table might look like this:
int id
int userid
int bookid
currently my loans entity has now created this:
DTO Loans
int id
User user // user entity
Book book // book entity
im struggling to understand how this example would work in llblgen. can anyone assist with guidance or point me in the way of a tutorial?
at the moment, when i come up to update my model Book with a new loan associated to a book, im getting stackoverflow errors. i assume this is creating some sort of loop when attempting to update my Book object.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我注意到在 SQL 上运行探查器时,sql 语句不包含任何连接到我的关系实体的语句。
这是因为我的域查询不包含我的关系的预取项目,我在查询中添加了以下内容:
i noticed when running a profiler on SQL that the sql statement didnt include any join statements onto my relationship entities.
this was because my domain query didnt include prefetch items for my relationships, i added the following to my query:
为了确保这一点,您正在查找已借出特定图书实体的用户实体的列表。这是正确的用例,还是您正在寻找借阅特定书籍的用户实体列表?
无论如何,LLBLGen 对这些案例的支持非常好,可以快速轻松地引用实体之间的关系并使用相关实体。
假设您正在通过唯一的 BookId/ISBN/等查找一本书......
假设您已经定义了实体之间的关系,就这么简单。
To make sure, you are looking for a list of User entities that have loaned a particular Book entity. Is this the correct use case, or are you looking for a list of User entities that have borrowed the particular book?
Regardless, LLBLGen's support for these cases is great with referencing relationships between entities and using related entities quickly and easily.
Presuming you're looking up a book by unique BookId/ISBN/etc....
It's just that simple assuming you've defined your relationships between entities.