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

  • SEARCH
  • Home
  • 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 8772573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:04:00+00:00 2026-06-13T18:04:00+00:00

I’m using Code First and am trying to call a stored procedure and have

  • 0

I’m using Code First and am trying to call a stored procedure and have it map to one of my classes. I created a stored procedure, BOMComponentChild, that returns details of a Component with information of its hierarchy in PartsPath and MyPath. I have a class for the output of this stored procedure. I’m having an issue where everything except the two columns, PartsPath and MyPath, are being mapped correctly with these two properties ending up as Nothing. I searched around and from my understanding the mapping bypasses any Entity Framework name mapping and uses column name to property name. The names are the same and I’m not sure why it is only these two columns.

The last part of the stored procedure is:

SELECT   t.ParentID
        ,t.ComponentID
        ,c.PartNumber
        ,t.PartsPath
        ,t.MyPath
        ,t.Layer
        ,c.[Description]
        ,loc.LocationID
        ,loc.LocationName
        ,CASE WHEN sup.SupplierID IS NULL THEN 1 ELSE sup.SupplierID END AS SupplierID
        ,CASE WHEN sup.SupplierName IS NULL THEN 'Default' ELSE sup.SupplierName END AS SupplierName
        ,c.Active
        ,c.QA
        ,c.IsAssembly
        ,c.IsPurchasable
        ,c.IsMachined
        ,t.QtyRequired
        ,t.TotalQty

FROM    BuildProducts                       t 
        INNER JOIN [dbo].[BOMComponent]     c       ON c.ComponentID    = t.ComponentID         
        LEFT JOIN [dbo].[BOMSupplier]       bsup    ON bsup.ComponentID = t.ComponentID AND bsup.IsDefault = 1
        LEFT JOIN [dbo].[LookupSupplier]    sup     ON sup.SupplierID   = bsup.SupplierID
        LEFT  JOIN [dbo].[LookupLocation]   loc     ON loc.LocationID   = c.LocationID
WHERE 
        (@IsAssembly IS NULL OR IsAssembly = @IsAssembly)
ORDER BY
         t.MyPath

and the class it maps to is:

Public Class BOMComponentChild

        Public Property ParentID As Nullable(Of Integer)
        Public Property ComponentID As Integer
        Public Property PartNumber As String
        Public Property MyPath As String
        Public Property PartsPath As String
        Public Property Layer As Integer
        Public Property Description As String
        Public Property LocationID As Integer
        Public Property LocationName As String
        Public Property SupplierID As Integer
        Public Property SupplierName As String
        Public Property Active As Boolean
        Public Property QA As Boolean
        Public Property IsAssembly As Boolean
        Public Property IsPurchasable As Boolean
        Public Property IsMachined As Boolean
        Public Property QtyRequired As Integer
        Public Property TotalQty As Integer

        Public Property Children As IDictionary(Of String, BOMComponentChild) = New Dictionary(Of String, BOMComponentChild)

    End Class

I am trying to call it like this:

Me.Database.SqlQuery(Of BOMComponentChild)("EXEC [BOMComponentChild] @ComponentID, @PathPrefix, @IsAssembly", params).ToList()

When I run the stored procedure in management studio, the columns are correct and not null. I just can’t figure out why these won’t map as they are the important information in the stored procedure. The types for PartsPath and MyPath are varchar(50).

EDIT

So I realized the only difference between those columns and the other ones is that they are made with casts. I replaced them in the end select with a static string and they were mapped correctly. When i replaced the last select with the ‘test’ i get the values are mapped. What is wrong with my CASTs if they are displayed correctly on in a SQL query.

;WITH BuildProducts ( ParentID, ComponentID, PartNumber
                    ,PartsPath, MyPath, QtyRequired, TotalQty, Layer)
AS
(
    SELECT   ...
            ,@PathPrefix                        AS PartsPath
            ,CAST(@PathPrefix +  
                    CAST(ComponentID            AS varchar(4))  +
                    '/'                         AS varchar(50)
                  )                             AS MyPath
            ,... 
    FROM    [dbo].[BOMComponent]            
    WHERE   ...

    UNION ALL

    SELECT   ...
            ,CAST(b.PartsPath + 
                    CAST(a.ParentID             AS varchar(4))  +
                    '/'                         AS varchar(50)
                  )                             AS PartsPath
            ,CAST(b.PartsPath + 
                    CAST(a.ParentID             AS varchar(4))  +
                    '/'                                         +
                    CAST(a.ComponentID          AS varchar(4))  +
                    '/'                         AS varchar(50)
                  )                             AS MyPath
            ,...
    FROM    [dbo].[BOMAssembly]             a 
            INNER JOIN [dbo].[BOMComponent] c ON a.ComponentID = c.ComponentID
            ...
)

SELECT  -- t.PartsPath
        --,t.MyPath
        'test' As PartsPath
        ,'test' As MyPath
        ,...

FROM    BuildProducts                       t 
        ...
  • 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-13T18:04:01+00:00Added an answer on June 13, 2026 at 6:04 pm

    In my infinite wisdom I had the parameter PathPrefix default to ‘/’ in my query, however, I was passing in PathPrefix as DBNull, which is not the same as not passing in a value. So the NULL propagated through the query.

    Sorry if I wasted anyone’s time.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.