How to add an additional output column for ProductLoadAllPaged stored procedure NC 4.2

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
New York wrote:
RE: "... I can do this by calling a function straight from razor on the page and bypass the Model, but for a page of 30 products, that would be 30 separate calls to the database - so I don't wish to do it this way.  ".

Maybe a bit of a hack, but you could create your own stored procedure to return all your columns.  One call with a CSV list of product ids.  If you have SQL 2016 or greater use you can use STRING_SPLIT - e.g.
SELECT * FROM Product WHERE Id in (SELECT value FROM STRING_SPLIT('1,2,3,4', ','))


Unfortunately, this also requires another field being returned. Since EF is 1-1 and expects output that matches a table, I can't really use this method (unless, of course, I call it from the razor page).   I can, however, use an output parameter (I did this for my Next/Prev paging - a CSV of all product Ids, found where the current id was in the string, and created a previous link w/the id before it and a next link w/the id after it).  Adding to the model should be simple, but table restrictions for one-way procedures are ludicrous.
3 years ago
Would it work to ignore property in the EF  domain > table mapping? Then field is not required in the db.

in ProductMap.cs

builder.Ignore(p => p.SqFtInStock);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.