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;
               }
    
           }
        }
    }
  • 相关阅读:
    PCI总线原理(二)
    smbus协议
    PCI总线原理(一)
    计算机术语中关于 Assert 和Deassert 词汇意思
    用安全存储器实现FPGA的身份识别及防拷贝
    主板结构
    qt 雅黑字体
    PCIExpress总线简介
    PHY管理接口(MDIO)
    PCI总线原理(三)
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3662957.html
Copyright © 2011-2022 走看看