NH > How to set lazy load for a single column in a table

Posts   
 
    
Posts: 14
Joined: 20-Apr-2016
# Posted on: 20-Apr-2016 20:46:50   

I have a table that looks like this:

CREATE TABLE ref_documents( document_id int IDENTITY(1,1), descriptions xml NOT NULL, doc_type nvarchar(20) NOT NULL, is_external tinyint NOT NULL CHECK (is_external in (0, 1)), external_path nvarchar(200) NULL, data varbinary(max) NULL, comments nvarchar(2000) NULL, is_active tinyint NOT NULL CHECK (is_active in (0, 1)), CONSTRAINT pk_rf_doc PRIMARY KEY CLUSTERED (document_id) )

I want to ensure that the "data" column is not loaded unless I explicitly reference it.

I can mark the property (in the mapping) to be lazy load, but cannot see how to mark an individual column in LLBLGen Pro (V4.2).

Is this possible? If not, I think this would be a great feature. I have a number of similar tables and this would be a big help.

Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Apr-2016 07:43:23   

Yes, you can exclude some field from being fetched. This section in the documentation explains how.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 21-Apr-2016 09:40:23   

If you mean for NHibernate, then you can't define it in the mappings.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 14
Joined: 20-Apr-2016
# Posted on: 21-Apr-2016 21:27:42   

So is this a feature that you will consider adding?

It is really a pain to have to hand modify each class that has a field/property like this.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Apr-2016 10:22:45   

What do you mean by hand modifying?

Posts: 14
Joined: 20-Apr-2016
# Posted on: 22-Apr-2016 10:49:56   

Take a look at the following.

Notice the "LazyLoad" on the Data column. I have to add that manually since LLBLGen Pro doesn't support it.


    /// <summary>Represents the mapping of the 'IdMultiTextActive.RefDocument' entity, represented by the 'RefDocument' class.</summary>
    public partial class RefDocumentMap : ClassMap<RefDocument>
    {
        /// <summary>Initializes a new instance of the <see cref="RefDocumentMap"/> class.</summary>
        public RefDocumentMap()
        {
            Table("[ref_documents]");
            OptimisticLock.None();

            Id(x=>x.Id)
                .Access.CamelCaseField(Prefix.Underscore)
                .Column("[document_id]")
                .GeneratedBy.Identity();
            Map(x=>x.Comments).Length(2000).Column("[comments]").Access.CamelCaseField(Prefix.Underscore);
           Map(x => x.Data).CustomType("BinaryBlob").Column("[data]").Access.CamelCaseField(Prefix.Underscore).LazyLoad();
            Map(x=>x.Descriptions).CustomType(typeof(ATS.Inspect.Shared.NHibernate.TypeConverters.LanguageIdTextTypeConverter)).Column("[descriptions]").Not.Nullable().Access.CamelCaseField(Prefix.Underscore);
            Map(x=>x.DocType).Length(20).Column("[doc_type]").Not.Nullable().Access.CamelCaseField(Prefix.Underscore);
            Map(x=>x.ExternalPath).Length(200).Column("[external_path]").Access.CamelCaseField(Prefix.Underscore);
            Map(x=>x.IsActive).CustomType(typeof(ATS.Inspect.Shared.NHibernate.TypeConverters.BooleanTypeConverter)).Column("[is_active]").Not.Nullable().Access.CamelCaseField(Prefix.Underscore);
            Map(x=>x.IsExternal).CustomType(typeof(ATS.Inspect.Shared.NHibernate.TypeConverters.BooleanTypeConverter)).Column("[is_external]").Not.Nullable().Access.CamelCaseField(Prefix.Underscore);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 25-Apr-2016 16:39:59   

It's indeed currently not supported, but it's a good suggestion. We'll look into adding this in the near future.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 18-Sep-2017 11:49:47   

Implemented in v5.3 (Post EAP)

Frans Bouma | Lead developer LLBLGen Pro