【发布时间】:2013-10-06 12:05:07
【问题描述】:
我有一个快速的 SQL 问题。 在我的 MVC Razor 应用程序中,我有两个文本输入要求输入开始值和结束值。
这些值将是数字,它们对应于版本 例如:4.0.100 - 4.0.157
所以我需要显示 100 - 157 之间的所有版本 我可以直接访问他的数据库,它是版本列
我的问题是:如何编写或获取查询以显示此内容?
型号:
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()" });
}
我访问文本输入的控制器类:
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。如果您不太了解 sql,Linq 可能是最简单的。
-
您使用的是哪个数据库?
-
我正在使用构建数据库。
标签: c# asp.net sql asp.net-mvc razor