How do I output ISingleResult from storeprocedure to view ?

Last post 07-03-2009 5:51 PM by CodeHobo. 1 replies.

Sort Posts:

  • How do I output ISingleResult from storeprocedure to view ?

    07-03-2009, 8:32 AM
    • Member
      point Member
    • Reflector
    • Member since 07-03-2009, 12:23 PM
    • Posts 1

    private storeprocDataContext sp = new storeprocDataContext();
    
    public ActionResult Index()
    {
    	ISingleResult<spGetResult> r = sp.spGet();
    	return View(r.ToList()); 
    }

    The above will throw an Error as "ISingleResult" cant be outputed to view so what do I do ?

    Filed under:
  • Re: How do I output ISingleResult from storeprocedure to view ?

    07-03-2009, 5:51 PM
    • Participant
      1,375 point Participant
    • CodeHobo
    • Member since 08-17-2005, 2:58 PM
    • Southern California
    • Posts 242

    Is it a strongly typed view? If so what is the type defined? At the top of your view you should have something like this

    Inherits="System.Web.Mvc.ViewPage<ISingleResult<spGetResult>>"

    If you don't want to use a strongly typed view you can still send the object to the View using the ViewData dictionary like so

    ViewData["result"]=r;


    Then in the View you can extract that data like so

    var result = ViewData["result"] as ISingleResult<spGetResult>;

Page 1 of 1 (2 items)