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 9077993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:30:38+00:00 2026-06-16T19:30:38+00:00

Possible Duplicate: Get values in NotMapped property in model class Entity Framwork Code First

  • 0

Possible Duplicate:
Get values in NotMapped property in model class Entity Framwork Code First using linq

I am using Entity Framework 5‘s Code First in my project and my model looks more or less like this:

public class Category
{
    public int CategoryId { get; set; }
    public string Name { get; set; }

    public virtual Category Parent { get; set; }

    [NotMapped]
    public int Level { get; set; }
}

The generated table contains all columns except the Level column (as expected)

Now, I have a stored procedure which calculates the Level of the Category node in relation to it’s parent.

If I execute the stored procedure in SQL Server Mgmt Studio it returns the columns as specified in my model including the [NotMapped] Level column.

The thing is: the Level column is not filled if I call the stored procedure like this: Context.Database.SqlQuery<TModel>(storedProcedure, parameterArray); where TModel is Category.

Is there any way to ‘re-use’ this Category model?

  • 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-06-16T19:30:39+00:00Added an answer on June 16, 2026 at 7:30 pm

    You clearly say that the property “Level” is not part of your model, therefor it of course won’t be filled by your stored procedure. Why would you expect any else?

    The only way would be to parse the result of your sp by hand and create instances of your model class yourself.

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

Sidebar

Related Questions

Possible Duplicate: How to Get Row values in Context menu using cursor? I have
Possible Duplicate: Get attribute values as array from selection of elements using jQuery I
Possible Duplicate: Array unique values Get unique results from JSON array using jQuery Im
Possible Duplicate: PHP get both array value and array key I am using Codeigniters'
Is it possible to get which values are duplicates in a list using python?
Possible Duplicate: Get the resolution of a jpeg image using C# and the .NET
Possible Duplicate: Get the IP Address of local computer Obtaining local IP address using
Possible Duplicate: PHP Built-in Method to Get Array Values Given a List of Keys
Possible Duplicate: Passing varible types though mod-rewrite howdy, I'm using the get method on
Possible Duplicate: is there any way to get common values between two arrays in

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.