在部分视图中加载存储过程时出现 ASP.NET MVC 2.0 堆栈溢出
新手如有错误,敬请谅解。
我正在 MVC 2.0 中编写一个收据详细信息查找工具,用于从我们的 POS 数据库中提取收据详细信息。我编写了返回我需要的数据的存储过程。我已将存储过程加载到存储库中。当我尝试在部分视图中加载这些存储过程时,出现堆栈溢出错误。如果我直接在视图中加载相同的代码,它就可以正常工作。我错过了什么吗?
存储库条目
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace CSTools.Models
{
public class QueryRepository
{
RDataContext DB = new RDataContext();
public IEnumerable<CSTools.Models.spGetReceiptDataResult> GetReciptData(int storeID, int transactionNumber)
{
var recipt = from rc in DB.spGetReceiptData(storeID, transactionNumber)
select rc;
return recipt;
}
}
}
控制器:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CSTools.Models;
namespace CSTools.Controllers
{
public class RetailController : Controller
{
QueryRepository Queries = new QueryRepository();
//
// GET: /Trackside/
public ActionResult Index()
{
return View();
}
public ActionResult ReceiptView()
{
return View();
}
public ActionResult ReceiptDataView(int storeID, int transactionNumber)
{
var Receipt = Queries.GetReciptData(storeID, transactionNumber);
return View(Receipt);
}
}
}
查看:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
ReceiptView
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>ReceiptView</h2>
<% Html.RenderPartial("ReceiptView"); %>
</asp:Content>
谢谢!
尼尔
Please forgive any newbie mistakes.
I'm writing a receipt detail lookup tool in MVC 2.0 to pull up receipt details from our POS database. I have the stored procedures written that return the data that I need. I have my sprocs loaded in a repository. When I try and load these sprocs in a partial view I get a stack overflow error. If I load the same code directly in the view it works fine. Am I missing something?
Repository entry
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace CSTools.Models
{
public class QueryRepository
{
RDataContext DB = new RDataContext();
public IEnumerable<CSTools.Models.spGetReceiptDataResult> GetReciptData(int storeID, int transactionNumber)
{
var recipt = from rc in DB.spGetReceiptData(storeID, transactionNumber)
select rc;
return recipt;
}
}
}
Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CSTools.Models;
namespace CSTools.Controllers
{
public class RetailController : Controller
{
QueryRepository Queries = new QueryRepository();
//
// GET: /Trackside/
public ActionResult Index()
{
return View();
}
public ActionResult ReceiptView()
{
return View();
}
public ActionResult ReceiptDataView(int storeID, int transactionNumber)
{
var Receipt = Queries.GetReciptData(storeID, transactionNumber);
return View(Receipt);
}
}
}
View:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
ReceiptView
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>ReceiptView</h2>
<% Html.RenderPartial("ReceiptView"); %>
</asp:Content>
Thanks!
Neil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论