开发者

ASP.NET MVC 2: Calling Stored Procedure, Getting Multiple ResultSets

How on earch can I access the second, third, fourth result sets?

Controller:

var dataContext = new DealDataContext();
XElement xmlString = new XElement("asd");
var deals = dataContext.spSearchDeals(xmlString);
return View(deals);

View:

<% foreach (spSearchDealsResult d in (IEnumerable)ViewData.Model)
 { %>

    <li> <%: d.TagLabel  %> </li>

<% } %>

This as simple as it gets... but I can only access the very first resulse开发者_JAVA百科t. HELP!


Yup, a known limitation/pet hate with Linq To Sql. When you drop stored procs on the canvas, L2SQL generates a method with return type ISingleResult<T>.

The workaround is to use Entity Framework...

Just kidding, here is the L2SQL workaround.

Basically you change the return type to IMultipleResult<T>. (who knew)

On a side note - why are you iterating through items in the ViewData? You are returning the model in the View, you should bind to that model directly.

E.g

Inherits="System.Web.Mvc.ViewPage<IEnumerable<SearchDeal>>"

and then:

<% foreach (var deal in Model.SearchDeals) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜