zoukankan      html  css  js  c++  java
  • LINQ.CS

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Zdsoft.DAL
    {
       public  class LINQ
        {
           MyDataContext context = new MyDataContext();
           //context.DeferredLoadingEnabled = false;
           public IList<Student> Search(Student stu)
           {
              
               var r = (from n in context.Student where n.StudentNumber == stu.StudentNumber select n).ToList<Student>();
               return r;
           }
           public IList<Student> SearchAll()
           {       
               var r = (from n in context.Student select n).ToList<Student>();
               return r;
           }
           public IList<Major> SearchMajor()
           {
               var r = (from n in context.Major select n).ToList<Major>();
               return r;
           }
           public IList<Department> SearchDepartment()
           {
               var r = (from n in context.Department select n).ToList<Department>();
               return r;
           }
           public IList<Nationality> SearchNationality()
           {
               var r = (from n in context.Nationality select n).ToList<Nationality>();
               return r;
           }
           
           public IList<Class> SearchClss()
           {
               var r = (from n in context.Class select n).ToList<Class>();
               return r;
           }
           public void Add(Student stu)
           {
               context.Student.InsertOnSubmit(stu);
               context.SubmitChanges();
           }
           public void Up(Student ya)
           {
               var t = context.Student.Single(e => e.StudentNumber == ya.StudentNumber);
               t.StudentName = ya.StudentName;
               t.Gender = ya.Gender;
               t.Identification = ya.Identification;
               t.MajorID = ya.MajorID;
               t.Birthday = ya.Birthday;
               t.ParentName = ya.ParentName;
               t.Telephone = ya.Telephone;
               t.NationalityID = ya.NationalityID;
               t.ClassID = ya.ClassID;
               t.Address = ya.Address;
               context.SubmitChanges();
           }
           public void del(Student ya)
           {
    
               var s = (from n in context.Student where n.StudentNumber == (ya.StudentNumber) select n).FirstOrDefault();
               if (s != null)
               {
                   context.Student.DeleteOnSubmit(s);
                   context.SubmitChanges();
               }
               else
               {
                   return;
               }
    
           }
        }
    }
  • 相关阅读:
    通过w3c方式 读取xml内容
    ssm项目 maven 项目pon.xml 配置
    myeclipse 2014新建maven web 项目步骤
    Maven学习
    常用正则学习
    Maven 那点事儿
    Chrome 里的请求报错 " Provisional headers are shown"
    php框架thinkphp3.2.3 配置文件bug
    $_GET $_POST $_REQUEST
    php检测函数
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3662957.html
Copyright © 2011-2022 走看看