using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using DataModel;
using Newtonsoft.Json;
namespace EFDAL
{
public class XueYuanClass
{
WlWcontext ConText = new WlWcontext();
/// <summary>
/// 数据显示连表联查
/// </summary>
/// <returns></returns>
public List<WuLianWangInfo> WlWInfos(string name = "")
{
var list = ConText.WlWtext.Include("JueseId").ToList();
if (!string.IsNullOrEmpty(name))
{
list = list.Where(s => s.Name.Contains(name)).ToList();
}
return list;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Did"></param>
/// <returns></returns>
public int DeleInfo(int Did)
{
var deid = ConText.WlWtext.Find(Did);
ConText.WlWtext.Remove(deid);
return ConText.SaveChanges();
}
/// <summary>
/// 修改数据
/// </summary>
/// <param name="wuLianWang"></param>
/// <returns></returns>
public int UpdateInfo(WuLianWangInfo wuLianWang)
{
ConText.WlWtext.Attach(wuLianWang);
ConText.Entry(wuLianWang).State = System.Data.Entity.EntityState.Modified;
return ConText.SaveChanges();
}
/// <summary>
/// 根据Id获取数据
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public WuLianWangInfo FanTian(int Id)
{
return ConText.WlWtext.Find(Id);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="WuLian"></param>
/// <returns></returns>
public int AddInfo(WuLianWangInfo WuLian)
{
ConText.WlWtext.Add(WuLian);
return ConText.SaveChanges();
}
/// <summary>
/// 调用分页存储过程
/// </summary>
/// <param name="Pageindex"></param>
/// <param name="Pagesize"></param>
/// <returns></returns>
public List<WuLianWangInfo> WPageProc(int Pageindex = 1,int Pagesize = 2)
{
var list = new List<WuLianWangInfo>();
int Pcount = 0;
SqlParameter Index = new SqlParameter("@PageIndex", Pageindex);
Index.Direction = ParameterDirection.Input;
SqlParameter Size = new SqlParameter("@PageSize", Pagesize);
Size.Direction = ParameterDirection.Input;
SqlParameter Count = new SqlParameter("@PageCount", Pcount);
Count.Direction = ParameterDirection.Output;
ConText.WlWtext.SqlQuery("exec Proc_Page", new SqlParameter[] { Index, Size, Count });
return list;
}
}
}