码迷,mamicode.com
首页 > 其他好文 > 详细

数据高级2

时间:2018-07-29 23:26:26      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:mode   nbsp   date   list()   color   data   put   and   model   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    using System.Data.Entity;
    using System.Data.SqlClient;
    using System.Data;
    using MODEL;
    public class StudentDAl
    {
        StudentDbContext dbcontext = new StudentDbContext();
        public int Add(int ClassCode, string StudentName, int Gender)
        {
            SqlParameter[] parameter = new SqlParameter[]
                {
                    new SqlParameter("@ClassCode",ClassCode),
                    new SqlParameter("@StudentName",StudentName),
                    new SqlParameter("@Gender",Gender)
                };
            return dbcontext.Database.ExecuteSqlCommand("exec proc_AddStudent @ClassCode,@StudentName,@Gender", parameter);

        }

        public List<AllData> GetStudent(SqlParameter[] parameter)
        {
            return dbcontext.Database.SqlQuery<AllData>("exec proc_getStudent @Dpage,@Count output,@ClassCode,@SchoolCode,@StudentName", parameter).ToList();
        }
        public int Delete(int StudentId)
        {
            return dbcontext.Database.ExecuteSqlCommand("exec proc_Delete @StudentId", new SqlParameter("@StudentId", StudentId));
        }
        public int Update(int ClassCode, string StudentName, int Gender,int StudentId)
        {
            SqlParameter[] parameter = new SqlParameter[]
                {
                    new SqlParameter("@ClassCode",ClassCode),
                    new SqlParameter("@StudentName",StudentName),
                    new SqlParameter("@Gender",Gender),
                    new SqlParameter("@StudentId",StudentId)
                      
                };
            return dbcontext.Database.ExecuteSqlCommand("exec proc_update @StudentId , @ClassCode , @StudentName , @Gender", parameter);

        }
        public AllData Getid(int StudentId)
        {
            var s = dbcontext.Database.SqlQuery<AllData>("exec get_fan @StudentId ", new SqlParameter("@StudentId", StudentId));
            return s.FirstOrDefault();
        }



    }
}

 

数据高级2

标签:mode   nbsp   date   list()   color   data   put   and   model   

原文地址:https://www.cnblogs.com/mamingyuan/p/9387942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!