C# web service 返回 自定义对象
本帖最后由 poor4pig 于 2013-09-04 11:18:28 编辑
User.cs 代码如下
***********************************************
namespace DataModel
{
[Serializable()]
public class
User
{
public User()
{
}
public User(int id,string name)
{
id = id;
name = name;
}
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
#region DB IO
public User RetrunUserSingle(SqlConnection connection)
{
using (SqlCommand command=connection.CreateCommand())
{
command.CommandText = "select * from [user] where ID=1";
SqlDataReader dr = command.ExecuteReader();
Reader(dr);
User user =new User(id,name);