关系和延迟加载在亚音速3.0 [英] Relationships and Lazy Loading in SubSonic 3.0

查看:190
本文介绍了关系和延迟加载在亚音速3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我亚音速3.0此刻玩弄,而且它看起来非常直接的(除了我还有SimpleRepository和ActiveRecord的之间的决定,但这是另一回事)。

I'm playing around with SubSonic 3.0 at the moment, and it looks really straight-forward (except that I still have to decide between SimpleRepository and ActiveRecord, but that's another story).

不过,由于文档是有点稀疏,我不知道这是否支持外国关系和延迟加载。从本质上讲,我有一类帖子:

However, as the documentation is a bit sparse, I am not sure if it supports foreign-relationships and lazy-loading. Essentially, I have a class posting:

public class Posting {
    [SubSonicPrimaryKey]
    public Guid InternalId { get; set; }
    public string Title { get; set; }
    public string Body { get; set; }
    public DateTime? PostingDate { get; set; }
    public List<Comment> Comments { get; set; }
}

和一类注释:

public class Comment
{
    public string Body { get; set; }
}

正如你看到的,过账有注释的清单。我能以某种方式告诉亚音速,这两个有关系吗?这是我可以自动保存所有评论当我救邮报?而更重要的是,当我打开一个帖子,我想评论的列表是空的,在第一,并在某些时候说:好吧,请立即填充它。

As you see, Posting has a List of Comments. Can I somehow tell SubSonic that these two are related? That is that I can automatically save all Comments when I save the Post? And more importantly, when I load a Posting, I'd like the List of Comments to be empty at first, and at some point say "Okay, please populate it now".

我知道我可以在code手动管理,但我只是想知道,如果亚音速​​能做到这一点之前,我做的手工工作。

I know I can manually manage this in Code, but I just like to know if SubSonic can do that before I do the manual work.

推荐答案

稀疏?你读过他们了吗?

Sparse? Have you read them yet?

ActiveRecord的可以判断你的人际关系基础上FKS(这样可以LINQ的模板),并使用IQueryable的。所以你得到两全其美 - 他们在那里,如果你需要他们。

ActiveRecord can determine your relationships based on FKs (so can the Linq Templates) and will use IQueryable. So you get the best of both worlds - they're there if you need them.

如果你使用简单回购 - 不 - 不这样做,它的全手动

If you use Simple Repo - no - this doesn't happen and it's all manual.

这篇关于关系和延迟加载在亚音速3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆