0

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 resulset. HELP!

RPM1984
  • 72,246
  • 58
  • 225
  • 350
dcolumbus
  • 9,596
  • 26
  • 100
  • 165

1 Answers1

1

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) %>
RPM1984
  • 72,246
  • 58
  • 225
  • 350
  • I'm not sure about Entity Framework, but what I'm trying to accomplish to just calling a sproc and getting the results. I don't want to have to deal with designing the schema, etc. I just want to call a sproc, receive the results and iterate through them and display them on the page. – dcolumbus Nov 25 '10 at 05:30
  • the "Entity Framework" statement was a joke. You don't have to touch the schema - you have a SPROC, you have added it to L2SQL designer, the article i added shows how to do what you want. What's the issue? – RPM1984 Nov 25 '10 at 05:41
  • The issue is that within the example you sent me, "typeof" relates to Table Entities that have been dragged into the designer. In my case, that's not what's going on... – dcolumbus Nov 25 '10 at 05:47
  • @dcolumbus - if you have a stored proc called `spSearchDeals` on your L2SQL designer, L2SQL will generate a partial class for you called `spSearchDealsResult` (look for it in the .designer.cs file). All you need to do is c+p that method, and change the return type to `IMultipleResult`. – RPM1984 Nov 25 '10 at 05:56
  • I really do appreciate your help, but I have no idea what "all you need to do is c+p that method" means. I've been thrown into this environment and I learn by example... I'm not deep enough into ASP.NET MVC to be able to conceptualize it in my head. – dcolumbus Nov 25 '10 at 06:20