Ejemplo n.º 1
0
 public static void Paging()
 {
     ODAContext ctx   = DBConfig.GetODAContext();
     int        total = 0;
     var        t     = ctx.GetCmd <CmdTest>();
     var        list  = t.SelectM(20 * 50, 50, out total);
 }
Ejemplo n.º 2
0
 public static void GetById()
 {
     using (SqlSugarClient conn = DBConfig.GetSugarConn())
     {
         var list2 = conn.Queryable <Test>().InSingle(1);
     }
 }
Ejemplo n.º 3
0
 public static void ReadData()
 {
     using (SqlSugarClient conn = DBConfig.GetSugarConn())
     {
         var list2 = conn.Queryable <Test>().ToList();
     }
 }
Ejemplo n.º 4
0
 public static void  Paging()
 {
     using (SqlSugarClient conn = DBConfig.GetSugarConn())
     {
         int total = 0;
         var list2 = conn.Queryable <Test>().ToPageList(20, 50, ref total);
     }
 }
Ejemplo n.º 5
0
        public static void Sql()
        {
            ODAContext ctx = DBConfig.GetODAContext();
            var        U   = ctx.GetCmd <CmdSysUser>();
            var        UR  = ctx.GetCmd <CmdSysUserRole>();

            var data = U.InnerJoin(UR, U.ColUserAccount == UR.ColUserAccount, UR.ColStatus == "O")
                       .Where(U.ColStatus == "O", U.ColEmailAddr.IsNotNull.Or(U.ColEmailAddr == "*****@*****.**"),
                              U.ColIsLocked == "N",
                              UR.ColRoleCode.In("Administrator", "Admin", "PowerUser", "User", "Guest"))
                       .Groupby(UR.ColRoleCode)
                       .Having(U.ColUserAccount.Count > 2)
                       .OrderbyAsc(U.ColUserAccount.Count)
                       .Select(U.ColUserAccount.Count.As("USER_COUNT"), UR.ColRoleCode);
        }
Ejemplo n.º 6
0
 public static void Sql()
 {
     using (SqlSugarClient db = DBConfig.GetSugarConn())
     {
         string[] roles = new string[] { "Administrator", "Admin", "PowerUser", "User", "Guest" };
         var      data  = db.Queryable <SYS_USER, SYS_USER_ROLE>((u, ur) => new object[] { JoinType.Inner, u.USER_ACCOUNT == ur.USER_ACCOUNT && ur.STATUS == "O" })
                          .Where((u, ur) => u.STATUS == "O" && (u.EMAIL_ADDR != null || u.EMAIL_ADDR == "*****@*****.**") && u.IS_LOCKED == "N" &&
                                 roles.Contains(ur.ROLE_CODE))
                          .GroupBy((u, ur) => ur.ROLE_CODE)
                          .Having(u => SqlFunc.AggregateCount(u.USER_ACCOUNT) > 2)
                          .OrderBy(u => SqlFunc.AggregateCount(u.USER_ACCOUNT))
                          .Select((u, ur) => new
         {
             USER_COUNT = SqlFunc.AggregateCount(u.USER_ACCOUNT),
             ROLE_CODE  = ur.ROLE_CODE
         }).ToDataTable();
     }
 }
Ejemplo n.º 7
0
 public static void ReadData()
 {
     ODAContext ctx  = DBConfig.GetODAContext();
     var        t    = ctx.GetCmd <CmdTest>();
     var        list = t.SelectM();
 }
Ejemplo n.º 8
0
 public static void GetById()
 {
     ODAContext ctx  = DBConfig.GetODAContext();
     var        t    = ctx.GetCmd <CmdTest>();
     var        list = t.Where(t.ColId == 1).SelectM();
 }