• 框架使用-Sql拼接


     Sql语句拼写:

    • 查询
      • DQueryDom
      • DmoQuery(返回的整个对象)
    • 更新
      • DQUpdateDom
    • 删除
      • DQDeleteDom
    • 条件
      • dom.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name","检修部"), DQCondition.Like("Spell", "检修部")));
    • 排序
      • dom.OrderBy.Expressions.Add(DQOrderByExpression.Create("OrderId",false));
    • 分组
      • dom.GroupBy.Expressions.Add(DQExpression.Field("Name"));
    • 自定义查询字段
      • dom.Columns.Add(DQSelectColumn.Field("ID"));

           

      • dom.Columns.Add(DQSelectColumn.Count());

           

    • 连接查询

      var user = new JoinAlias(typeof(WpfUser));

      var bindInfo = new JoinAlias(typeof(UserBindInfo));

      var dom = new DQueryDom(user);

      dom.From.AddJoin(JoinType.Left, new DQDmoSource(bindInfo), DQCondition.EQ(user, "ID", bindInfo, "User_ID"));

         

      dom.Columns.Add(DQSelectColumn.Field("ID"));

      dom.Columns.Add(DQSelectColumn.Field("Name"));

      dom.GroupBy.Expressions.Add(DQExpression.Field("ID"));

      dom.GroupBy.Expressions.Add(DQExpression.Field("Name"));

    • Session
      • using (var context = new TransactionContext())

        {

        context.Session.ExecuteNonQuery(update);

        context.Session.Commit();

        }

      using (IDmoSession session = Dmo.NewSession()) //好想要引用或者继承什么,否则session为null

      {

      var list = session.ExecuteList(query);

      return list.Cast<WXDept>().ToList();

      }

         

    • 执行方法
      • DQUpdateDom提交 ExecuteNonQuery
        context.Session.ExecuteNonQuery(update);

        context.Session.Commit();

      • DQDeleteDom提交 ExecuteNonQuery

        Session.ExecuteNonQuery(del);

      • DomQuery提交 ExecuteScalar

        var result = (WXAgent)Session.ExecuteScalar(dmo); //DomQuery

        return (long?)context.Session.ExecuteScalar(dom); //DQueryDom

           

         

      • ExecuteList

        using (var context = new TransactionContext())

        {

        var list = context.Session.ExecuteList(dmo);

        var userList = list.Cast<UserBindInfo>().ToList();

        UserBindInfo bindInfo = null;

        if (userList.Count > 0)

        {

        bindInfo = userList.First();

        }

        return bindInfo;

        }

      • ExecuteReader

        using (var context = new TransactionContext())

        {

        using (var reader = context.Session.ExecuteReader(dom))

        {

        while (reader.Read())

        {

        yield return new WordPair(reader[0].ToString(), TreeUtil.GetTreePrefix(Convert.ToInt32(reader[2])) + reader[1]);

        }

        }

        }

           

           

           

      using (IDmoSession session = Dmo.NewSession())

      {

      dtWeiXin = session.ExecuteSql(WxSql()).Tables[0];

      }

      using (IDmoSession session = Dmo.NewSession(ConfigurationManager.AppSettings["cfdBus"]))

      {

      //session.ExecuteSqlNonQuery(CfdBusSql(dtWeiXin));

      session.ExecuteSqlNonQuery(CfdBusSql(dtWeiXin));

         

      session.Commit();自定义sql要提交一下子

      }

         

         

         

       

       

       

       

    有些事现在不做,一辈子都不会做了
  • 相关阅读:
    2017/09/02笔记:ps
    207/08/3学习笔记:pc端网站如何实现移动端适配知识点
    2017/0828xueix笔记:图像替代文本&css绘制的图形
    20170824:面试题笔记
    目前比较全的CSS重设(reset)方法总结
    学习笔记:css3实现多行文字溢出显示省略号&display:box;
    SVG圆形<circle> 标签
    k8s节点分配nodeSelector, Affinity和Anti-Affinity 亲和性和反亲和性
    kubernetes网络介绍
    centos6.7 安装docker
  • 原文地址:https://www.cnblogs.com/mengkai/p/10819125.html
Copyright © 2020-2023  润新知