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;
               }
    
           }
        }
    }
  • 相关阅读:
    win7无法访问2003共享的解决方法(转)
    nokia vcf文件导入iphone(转)
    zblog之密码修改
    vs2010 dump 调试
    T400 CTO 突遇windows update当前无法检查更新,因为服务为运行。您可能需要重新启动计算机!
    练手卦,奖金何时发?
    QUdpSocket 4.6 严重丢包
    修行
    占问事宜:我买的择日书籍何时能到?
    Silverlight 5 Beta新特性[6]低延迟对WAV格式声音效果支持
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3662957.html
Copyright © 2011-2022 走看看