简体   繁体   English

NHibernate:延迟加载属性

[英]NHibernate: Lazy Loading Properties

So, according to Ayende Lazy Loading Properties are already in the NHibernate trunk. 因此,根据Ayende的说法,NHibernate主干中已经包含了Lazy Loading属性。

My Problem is: I can't use the trunk for I have FluentNHibernate and LinQ for NHibernate, so I depend on the version they are linked against (Versio 2.x). 我的问题是:我无法使用中继线,因为我有FluentNHibernate和LinQ用于NHibernate,所以我取决于它们所链接的版本(Versio 2.x)。 I can't and don't want to build all the assemblies myself against the newest version of NHibernate. 我不能也不想自己针对最新版本的NHibernate构建所有程序集。

So, has someone got information about when NHibernate 3.0 will leave Beta-Stadium and the auxiliaries (Linq etc.) will be compiled against it? 因此,是否有人知道NHibernate 3.0何时会离开Beta-Stadium以及针对它的助剂(Linq等)?

I appreciate any estimate! 我感谢任何估计!

I need this feature so I can use it on Blob-Fields. 我需要此功能,因此可以在Blob字段上使用它。 I don't want to use workarounds to destroy my object model. 我不想使用变通办法破坏我的对象模型。

You can compile Fluent with the NH 3.0 binaries, and you don't need L2NH anymore; 您可以使用NH 3.0二进制文件编译Fluent,并且不再需要L2NH。 there's a new integrated provider. 有一个新的集成提供商。

Alternatively it isn't much of a model change. 另外,这不是模型更改的主要内容。 Make a new class, Blob, that has Id, Version and Bytes properties, make a new table to match. 创建一个具有Id,Version和Bytes属性的新类Blob,以匹配一个新表。 Add the new class as a protected property to each of your classes that currently has a blob. 将新类作为受保护的属性添加到当前具有blob的每个类中。 Use it like a backing store. 像后备商店一样使用它。 Change your mapping to map the underlying property instead of the public one. 更改您的映射以映射基础属性,而不是公共属性。

public class MyClass
{
    public MyClass()
    {
        MyBlobProperty_Blob= new Blob();
    }

    public virtual byte[] MyBlobProperty
    {
        get { return MyBlobProperty_Blob.Bytes; }
    }

    protected virtual Blob MyBlobProperty_Blob { get; private set; }
}

It is a significant schema change however. 但是,这是一个重大的架构更改。 This particular solution moves all your binary data into one table. 这种特定的解决方案将所有二进制数据移动到一个表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM