[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Get list from context with storeproc

I want to have the results to a select list in my controller I want to do this instead of Linq.

 protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
    
        public DbSet<User> Users { get; set; }
        public DbSet<UserStore> UserStores { get; set; }
    
        public virtual ObjectResult<string> spGetStoreList(string userID)
        {
            var userIDParameter = userID != null ?
                new ObjectParameter("UserID", userID) :
                new ObjectParameter("UserID", typeof(string));
    
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<string>("spGetStoreList", userIDParameter);
        }


/######################## Excerpt # Stored procedure ###############
ALTER PROCEDURE [dbo].[spGetStoreList] 
  @UserID	VARCHAR(200)
AS
  SET NOCOUNT ON
select  StoreId from UserStore where UserID IN (SELECT UserKey from Users WHERE UserID = @UserId) ORDER BY StoreID
		

Open in new window

0
Seven price
Asked:
Seven price
1 Solution
 
Bob LearnedCommented:
I don't understand what you are looking for...
0
 
Seven priceFull StackAuthor Commented:
I got it.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now