WebApi项目代码
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Newtonsoft.Json;
using WebApplication1.Models;
using System.Web.Http.Results;
namespace WebApplication1.Controllers
{
public class ValuesController : ApiController
{
public const string constr = @"Data Source=.;Initial Catalog=UserInfo;User ID=dongcheng;Password=Aa336699";
public JsonResult<List<User>> GetAll()
{
List<User> userInfoList = new List<User>();
SqlConnection conn = new SqlConnection(constr);
string text = "userinfo_get";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(text, conn);
DataSet ds = new DataSet("Students");
da.Fill(ds);
DataTable dt = ds.Tables[0];
foreach (DataRow row in dt.Rows)
{