.netters Services构建SQL,不用存储过程
namespace Northwind.Services
{
/// <summary>
/// An component type implementation of the 'Employees' table.
/// </summary>
/// <remarks>
/// All custom implementations should be done here.
/// </remarks>
[CLSCompliant(true)]
public partial class EmployeesService : Northwind.Services.EmployeesServiceBase
{
Constructors Constructors
/// <summary>
/// GetEmployeesHiredBetween(DateTime startDate, DateTime endDate)
/// </summary>
/// <remarks>
/// GetEmployeesHiredBetween(DateTime startDate, DateTime endDate)
/// </remarks>
public TList<Employees> GetEmployeesHiredBetween(DateTime startDate, DateTime endDate)
{
EmployeesParameterBuilder pb = new EmployeesParameterBuilder();
pb.AppendRange(EmployeesColumn.HireDate, startDate.ToString(), endDate.ToString());
return DataRepository.EmployeesProvider.Find(pb.GetParameters());
}
//网友J.C 写: 构建SQL,不用存储过程
/*
public TList<InfoReply> GetInfoReplylist()
{
TList<InfoReply> list = new TList<InfoReply>();
string connectionString = ConfigurationManager.AppSettings["sqlConnection"];
SqlConnection conn = new SqlConnection(connectionString);
string sql = "select a.* from InfoReply as a inner join (select min(InfoReplyId) as InfoReplyId from InfoReply group by InfoId) as b on a.InfoReplyId=b.InfoReplyId ORDER BY a.InfoId DESC";
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
InfoReply NewInfo = new InfoReply();
NewInfo.Content = dr["Content"].ToString();
NewInfo.InfoId = int.Parse(dr["InfoId"].ToString());
NewInfo.InfoReplyId = int.Parse(dr["InfoReplyId"].ToString());
NewInfo.Ip = dr["Ip"].ToString();
NewInfo.OwnerId = int.Parse(dr["OwnerId"].ToString());
try
{
NewInfo.Recycle = bool.Parse(dr["Recycle"].ToString());
}
catch
{
NewInfo.Recycle = false;
}
NewInfo.ReplyTime = DateTime.Parse(dr["ReplyTime"].ToString());
NewInfo.ReplyType = int.Parse(dr["ReplyType"].ToString());
list.Add(NewInfo);
}
conn.Close();
return list;
}*/
}//End Class
} // end namespace
{
/// <summary>
/// An component type implementation of the 'Employees' table.
/// </summary>
/// <remarks>
/// All custom implementations should be done here.
/// </remarks>
[CLSCompliant(true)]
public partial class EmployeesService : Northwind.Services.EmployeesServiceBase
{
Constructors Constructors
/// <summary>
/// GetEmployeesHiredBetween(DateTime startDate, DateTime endDate)
/// </summary>
/// <remarks>
/// GetEmployeesHiredBetween(DateTime startDate, DateTime endDate)
/// </remarks>
public TList<Employees> GetEmployeesHiredBetween(DateTime startDate, DateTime endDate)
{
EmployeesParameterBuilder pb = new EmployeesParameterBuilder();
pb.AppendRange(EmployeesColumn.HireDate, startDate.ToString(), endDate.ToString());
return DataRepository.EmployeesProvider.Find(pb.GetParameters());
}
//网友J.C 写: 构建SQL,不用存储过程
/*
public TList<InfoReply> GetInfoReplylist()
{
TList<InfoReply> list = new TList<InfoReply>();
string connectionString = ConfigurationManager.AppSettings["sqlConnection"];
SqlConnection conn = new SqlConnection(connectionString);
string sql = "select a.* from InfoReply as a inner join (select min(InfoReplyId) as InfoReplyId from InfoReply group by InfoId) as b on a.InfoReplyId=b.InfoReplyId ORDER BY a.InfoId DESC";
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
InfoReply NewInfo = new InfoReply();
NewInfo.Content = dr["Content"].ToString();
NewInfo.InfoId = int.Parse(dr["InfoId"].ToString());
NewInfo.InfoReplyId = int.Parse(dr["InfoReplyId"].ToString());
NewInfo.Ip = dr["Ip"].ToString();
NewInfo.OwnerId = int.Parse(dr["OwnerId"].ToString());
try
{
NewInfo.Recycle = bool.Parse(dr["Recycle"].ToString());
}
catch
{
NewInfo.Recycle = false;
}
NewInfo.ReplyTime = DateTime.Parse(dr["ReplyTime"].ToString());
NewInfo.ReplyType = int.Parse(dr["ReplyType"].ToString());
list.Add(NewInfo);
}
conn.Close();
return list;
}*/
}//End Class
} // end namespace