using EmpSys.DBContext;
using System.Data.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
//using System.Data;
using System.Net.Http;
using System.Web.Http;
namespace EmpSys.Controllers
{
public class UserAPIController : BaseAPIController
{
public HttpResponseMessage Get()
{
return ToJson(EmpDB.TblEmp.AsEnumerable());
}
public HttpResponseMessage Post([FromBody]TblEmp value)
{
EmpDB.TblEmp.Add(value);
return ToJson(EmpDB.SaveChanges());
}
public HttpResponseMessage Put(int id, [FromBody]TblEmp value)
{
EmpDB.Entry(value).State = EntityState.Modified;
return ToJson(EmpDB.SaveChanges());
}
public HttpResponseMessage Delete(int id)
{
EmpDB.TblEmp.Remove(EmpDB.TblEmp.FirstOrDefault(x => x.Id == id));
return ToJson(EmpDB.SaveChanges());
}
}
}
当我尝试运行上面的代码时,出现以下错误:
与添加和删除类似。
如何为AsEnumerable和FirstOrDefault定义
答案 0 :(得分:0)
(even, odds) = pairify (partition even)
应该继承自EmpSys
。检查IEnumerable