SubSonic SubSonic.SqlQuery&日期

时间:2008-10-03 00:01:53

标签: subsonic date

SubSonic.SqlQuery是否有/和日期范围?如果没有,那么获得范围的最佳方法是什么。

3 个答案:

答案 0 :(得分: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

答案 1 :(得分: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

Query q = Table.CreateQuery() .BETWEEN_AND("Column", "1/1/2008", "12/31/2008"); data.LoadAndCloseReader(q.ExecuteReader()); // loop through collection

答案 2 :(得分: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