Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4335044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:36:57+00:00 2026-05-21T10:36:57+00:00

Is there a way when executing a stored procedure with NHibernate to return an

  • 0

Is there a way when executing a stored procedure with NHibernate to return an extra field that is not in the original model?

What I’m doing is creating a sproc to return search results of a Resource. It returns all of the normal fields of my Resource class, but also an extra field called Rank. Is there a way to map that on to the current Resource class (or even create a class that inherits from Resource and just adds that one property)?

The execution of my sproc is:

<sql-query name="GetRelatedResources">
    <return alias="item" class="ResourceRanked">
        <return-property column="Rank" name="Rank" />
        <return-property column="ResourceId" name="Id" />
        <return-property column="Name" name="Name" />
        <return-property column="Description" name="Description" />
        <return-property column="Filename" name="Filename" />
        <return-property column="Filetype" name="Filetype" />
        <return-property column="IsPublic" name="IsPublic" />
        <return-property column="IsFeatured" name="IsFeatured" />
        <return-property column="VideoEmbedCode" name="VideoEmbedCode" />
        <return-property column="VideoId" name="VideoId" />
        <return-property column="VideoPlayerId" name="VideoPlayerId" />
        <return-property column="VideoPlayerKey" name="VideoPlayerKey" />
        <return-property column="VideoHeight" name="VideoHeight" />
        <return-property column="VideoWidth" name="VideoWidth" />
        <return-property column="IsDeleted" name="IsDeleted" />
        <return-property column="CreatedOn" name="CreatedOn" />
        <return-property column="ModifiedOn" name="ModifiedOn" />
        <return-property column="CreatedBy" name="CreatedBy" />
        <return-property column="ModifiedBy" name="ModifiedBy" />
        <return-property column="CreatedByName" name="CreatedByName" />
        <return-property column="ModifiedByName" name="ModifiedByName" />
    </return>
    exec dbo.gbi_sp_GetRelatedResources :pageSize, :pageIndex, :resourceId
</sql-query>

And my class:

public class Resource : DomainEntity
{
    [Required(ErrorMessage = "Please enter a name"), StringLength(100, ErrorMessage = "Name length can not exceed 100 characters")]
    public virtual string Name { get; set; }

    [StringLength(200, ErrorMessage = "Description length can not exceed 200 characters")]
    public virtual string Description { get; set; }

    public virtual string Filename { get; set; }
    public virtual string Filetype { get; set; }

    public virtual bool IsPublic { get; set; }
    public virtual bool IsFeatured { get; set; }

    [StringLength(500, ErrorMessage = "Embed Code length can not exceed 500 characters")]
    public virtual string VideoEmbedCode { get; set; }
    public virtual long? VideoId { get; set; }
    public virtual long? VideoPlayerId { get; set; }
    [StringLength(100, ErrorMessage = "Player Key length can not exceed 100 characters")]
    public virtual string VideoPlayerKey { get; set; }
    public virtual int? VideoHeight { get; set; }
    public virtual int? VideoWidth { get; set; }

    //public virtual int Rank { get; set; }

    public virtual string Format { 
        get
        {
            if (ResourceFileType == ResourceFileType.EmbeddedVideo || ResourceFileType == ResourceFileType.VideoPlayer)
                return "Video";

            switch (Filetype)
            {
                case "pdf":
                    return "Adobe Acrobat";
                case "docx":
                case "doc":
                    return "Microsoft Word";
                case "ppt":
                case "pptx":
                    return "Microsoft PowerPoint";
                case "xls":
                case "xlsx":
                    return "Microsoft Excel";
                default:
                    return Filetype.ToUpper();
            }
        }
    }

    public virtual ResourceFileType ResourceFileType
    {
        get
        {
            if (VideoId.HasValue)
                return ResourceFileType.VideoPlayer;
            if (!VideoEmbedCode.IsNullOrEmpty() || VideoId.HasValue)
                return ResourceFileType.EmbeddedVideo;
            return ResourceFileType.Document;
        }
    }

    public virtual IEnumerable<Market> Markets { get; set; }
    public virtual IEnumerable<Workstream> Workstreams { get; set; }
    public virtual IEnumerable<Tag> Tags { get; set; }
    public virtual IEnumerable<Topic> Topics { get; set; }
    public virtual IEnumerable<ResourceType> Types { get; set; }

    public override string ToString()
    {
        return Id + " - " + Name;
    }
}

Ideally I’d like to just make a class like this to extend Resource

public class ResourceRanked : Resource
{
    public virtual int Rank { get; set; }
}

But I can’t get that to work unless I duplicate the xml mapping of the Resource class. I’ve looked at subclasses for nhibernate, but they don’t seem to fit what I’m trying to do.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:36:58+00:00Added an answer on May 21, 2026 at 10:36 am

    I couldn’t find any suitable solution that worked for me, so I unfortunately just had to map another class specifically for the return result of the stored proc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I check that a stored procedure exists using ADO.Net? Is there a
I'm executing one stored procedure from the '.net' code. Since there is a lot
Is there any way to run several SELECT statements concurrently inside a Stored Procedure
Is there a way to get the name of the currently executing method in
Is there a way to find the name of the program that is running
I need to retrieve the name of the stored procedure that a crystal report
Hope you can help. Is there a way to reliably detect when a stored
I have a stored procedure which is doing a lot of delete. Hundreds of
Is there a way to not display the number for a single li in
Is there any way to enable execution-time variable expansion for cmd.exe (normally done by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.