Solved

Get list from context with storeproc

Posted on 2013-11-05
2
227 Views
Last Modified: 2013-11-07
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
Comment
Question by:sevensnake77
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 39627997
I don't understand what you are looking for...
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 39631069
I got it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now