zoukankan      html  css  js  c++  java
  • Linq在Lims系统中的用法

     使用Linq的目的是为了保存大文本

    https://blog.csdn.net/weixin_30536513/article/details/97600630

    这段代码应该是更新操作

    FlowDataContext DCDC = new FlowDataContext();//数据上下文
    Config ce = new Config();//表格

    try
    {

       //ConfigID.Text是添加页面的隐藏字段
      ce = DCDC.Config.Single(p => p.ID.Equals(ConfigID.Text));
      ce.FlowType = DDl1.SelectedValue;
      ce.FlowName = TFlowName.Text;
      ce.FlowCode=TFlowCode.Text;
      ce.Remark = TRemark.Text;

        一旦调用 SubmitChanges() 就将这些改变保存到数据库中去。
           DCDC.SubmitChanges();
      Window1.Hidden = true;
      BindGrid1();

    }
    catch
    {

      

       添加数据到数据库中

             Flow.Config表中的ID应该是Guid.NewGuid();

      System.Guid guid = new Guid();
      guid = Guid.NewGuid();

      Config c = new Config();
      c.ID = guid.ToString();
      c.FlowName = TFlowName.Text;
      c.FlowType = DDl1.SelectedValue;
      c.FlowCode = TFlowCode.Text;
      c.Remark = TRemark.Text;
      DCDC.Config.InsertOnSubmit(c);

         //保存到数据库
           DCDC.SubmitChanges();
           Window1.Hidden = true;
           BindGrid1();

    }

    查询列表中的内容

    if (KeyWord.Text.Length > 0)
    {
      FlowDataContext DCDC = new FlowDataContext();
      var query = DCDC.Config.Where(fc => fc.FlowName.Contains(KeyWord.Text) || fc.FlowType.Contains(KeyWord.Text) ||  

      fc.FlowCode.Contains(KeyWord.Text));           
      //此段代码就是将json类型的数组,变成DataTable
      return Govaze.Components.DataTableExtensions.ToDataTable(query);
    }

    else
    {
      FlowDataContext DCDC = new FlowDataContext();
      var query = from fc in DCDC.Config
      select fc;
      return Govaze.Components.DataTableExtensions.ToDataTable(query);
    }

    //删除语句

    FlowDataContext DC = new FlowDataContext();
    Config fc = new Config();
    fc = DC.Config.Single(p => p.ID.Equals(Grid1.DataKeys[e.RowIndex][0].ToString()));
    foreach (Branch bh in fc.Branch)
    {

       foreach (Branch_Charge bc in bh.Branch_Charge)
      {
        DC.GetTable<Branch_Charge>().DeleteOnSubmit(bc);
      }
      DC.GetTable<Branch>().DeleteOnSubmit(bh);

    }

    DC.GetTable<Config>().DeleteOnSubmit(fc);

    //提交到数据库的意思
    DC.SubmitChanges();
    BindGrid1();

  • 相关阅读:
    Vulnhub_DC4 记录
    文件上传(解析)漏洞
    开源情报搜集
    Vulnhub_DC3 记录
    “恶意”利用IPC$
    Vulnhub_DC2 记录
    Vulnhub_DC1 记录
    合天网安实验室 渗透测试项目二
    合天网安实验室 渗透测试项目一
    编程如写作
  • 原文地址:https://www.cnblogs.com/sanshengshitouhua/p/14486960.html
Copyright © 2011-2022 走看看