我有一個快速的SQL問題。 在我的MVC Razor應用程序中,我有兩個文本輸入要求開始和結束值。asp.net mvc razor應用程序 - 從範圍內的數據庫中選擇數據
這些值將是數字,它們對應版本 例如:4.0.100 - 4.0.157
所以我需要100之間,以顯示所有版本 - 157我有TOT他直接訪問數據庫,它的版本列
我的問題是:我如何編寫或獲取查詢來顯示此?
型號:
using System;
using System.Collections.Generic;
namespace BenchmarkApp.Models
{
public partial class Build
{
public Build()
{
this.Executions = new List<Execution>();
}
public string Version { get; set; }
public bool Obfuscated { get; set; }
public bool Release { get; set; }
public int ID { get; set; }
public bool IsX64 { get; set; }
public bool Visible { get; set; }
public Nullable<System.DateTime> CreationDate { get; set; }
public virtual ICollection<Execution> Executions { get; set; }
}
}
.cshtml示出兩個輸入端的視圖:
<td>
Viewing Option: @Html.DropDownList("ViewOption", (IEnumerable<SelectListItem>)ViewBag.ViewSelect, new { @onchange = "submit()" })
</td>
<td>
@if (ViewBag.RangeVisible == true)
{
@Html.Label("Range: ");
@Html.TextBox("start", "Start", new { maxlength = 10, size = 10 });
@Html.TextBox("end", "End", new { maxlength = 10, size = 10, @onchange = "submit()" });
}
Controller類,其中i訪問文本輸入:
string start = form["start"];
string end = form["end"];
string custom = form["customRange"];
string viewSelect = form["ViewOption"];
if (viewSelect.Equals("range"))
{
ViewBag.RangeVisible = true;
}
謝謝你前進!
那麼你可以做linq to sql,一個存儲過程,或者只是在頁面上寫出sql。 Linq可能是最簡單的,如果你不知道多少SQL。 –
你正在使用哪個數據庫? – mecek
即時通訊使用構建數據庫。 –