SubSonic.SqlQuery 是否有一个介于/和的日期范围?如果不是,那么获得范围的最佳方法是什么。
madcolor
问问题
1411 次
3 回答
3
尝试这样的事情:
SqlQuery query = new SqlQuery().From("Table")
.WhereExpression("Column")
.IsBetweenAnd("1/1/2008", "12/31/2008");
DataSet dataSet = query.ExecuteDataSet(); // Or whatever output you need
于 2008-10-03T00:31:17.007 回答
2
使用 SubSonic 进行查询的另一种方法。
TableCollection data = new TableCollection();
Query q = Table.CreateQuery()
.BETWEEN_AND("Column", "1/1/2008", "12/31/2008");
data.LoadAndCloseReader(q.ExecuteReader());
// loop through collection
于 2008-10-09T03:52:02.990 回答
0
结合罗斯文的答案:
SqlQuery query = new SqlQuery().From("Orders")
.WhereExpression("OrderDate")
.IsBetweenAnd("1996-07-02", "1996-07-08");
DataSet dataSet = query.ExecuteDataSet(); // Or whatever output you need
#region PresentResultsReplaceResponseWriteWithConsole.WriteLineForConsoleApp
DataTable dt = dataSet.Tables[0];
Response.Write("<table>");
foreach ( DataRow dr in dt.Rows )
{
Response.Write("<tr>");
for (int i = 0; i < dt.Columns.Count; i++)
{
Response.Write("<td>");
Response.Write(dr[i].ToString() + " ");
Response.Write("<td>");
} //eof for
Response.Write("</br>");
Response.Write("</tr>");
}
Response.Write("<table>");
#endregion PresentResultsReplaceResponseWriteWithConsole.WriteLineForConsoleApp
于 2009-06-02T18:27:31.047 回答