这是完整的错误消息:方法'Skip'仅支持LINQ to Entities中的排序输入.必须在方法'Skip'之前调用'OrderBy'方法
在"PurchaseOrderController"中,我已将此代码添加到索引方法中:
// GET: PurchaseOrder
public ActionResult Index(int? page)
{
return View(db.PurchaseOrders.ToPagedList(page ?? 1, 3));
}
Run Code Online (Sandbox Code Playgroud)
同样在"PurchaseOrders"的索引视图中,我添加了以下代码:
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<PurchaseOrders.Models.PurchaseOrder>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.First().PurchaseRequest_)
</th>
<th>
@Html.DisplayNameFor(model => model.First().Date)
</th>
<th>
@Html.DisplayNameFor(model => model.First().Requestor)
</th>
<th>
@Html.DisplayNameFor(model => model.First().Vendor)
</th>
<th>
@Html.DisplayNameFor(model => model.First().DateOrdered)
</th>
<th>
@Html.DisplayNameFor(model => model.First().ConfirmedWith)
</th>
<th>
@Html.DisplayNameFor(model => model.First().WorkOrder_)
</th>
<th></th>
</tr>
Run Code Online (Sandbox Code Playgroud) 我正在使用PagedList.Mvc,并且添加了一种在mvc Web应用程序中的各个页面之间导航的好方法。但是,当我单击“编辑”或“详细信息”选项卡并保存更改时,我将被发送回第一页。我想保留在进行更改的同一页面上。
这是我在控制器中的代码:
// GET: Item
public ActionResult Index(int? page)
{
var items = db.Items.Include(i => i.PurchaseOrder);
return View(items.ToList().ToPagedList(page ?? 1, 3));
}
Run Code Online (Sandbox Code Playgroud)
这是视图中的代码:
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<PurchaseOrders.Models.Item>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.First().ItemDescription)
</th>
<th>
@Html.DisplayNameFor(model => model.First().Quantity)
</th>
<th>
@Html.DisplayNameFor(model => model.First().Price)
</th>
<th>
@Html.DisplayNameFor(model => model.First().DueDate)
</th>
<th>
@Html.DisplayNameFor(model => model.First().DateReceived)
</th>
<th>
@Html.DisplayNameFor(model => model.First().Comments)
</th>
<th>
@Html.DisplayNameFor(model => model.First().PurchaseOrder.PurchaseRequest_)
</th>
<th></th> …Run Code Online (Sandbox Code Playgroud) 我写了一个应用程序,它读取一个由数字组成的文本文件,然后将它们转换为双数组,然后对我计算平均值,标准偏差,方差等的数字执行一些数学计算.
我的问题是,如果文本文件包含大量值,我如何调整/设置数组只采用前50个值?
这是我的代码:
FileReaderClass fr = new FileReaderClass();
CalculatorClass calc = new CalculatorClass();
string[] readText = fr.ReadFile(fileName);
double[] data = fr.ConvertToDoubleArray(readText);
if (data.Length < 5)
{
MessageBox.Show("There are not enough data points in this file to perform the calculation.");
return;
}
else if (data.Length > 50)
{
//limit the array to the first 50 values. Then perform the calculations...
}
//else perform the calculations.....
Run Code Online (Sandbox Code Playgroud)