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;
               }
    
           }
        }
    }
  • 相关阅读:
    css3变换与过度
    之前做过的js练习题
    关于js中的array部分
    js复习内容
    关于js封装函数的一些东西
    html中padding和margin的区别和用法与存在的bug消除
    JS 实现百度搜索功能
    JS正则表达式的基础用法
    CSS3 动画及过渡详解
    JS的for循环小例子
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3662957.html
Copyright © 2011-2022 走看看