Exemple #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);
 }
Exemple #2
0
 public static void GetById()
 {
     using (SqlSugarClient conn = DBConfig.GetSugarConn())
     {
         var list2 = conn.Queryable <Test>().InSingle(1);
     }
 }
Exemple #3
0
 public static void ReadData()
 {
     using (SqlSugarClient conn = DBConfig.GetSugarConn())
     {
         var list2 = conn.Queryable <Test>().ToList();
     }
 }
Exemple #4
0
 public static void  Paging()
 {
     using (SqlSugarClient conn = DBConfig.GetSugarConn())
     {
         int total = 0;
         var list2 = conn.Queryable <Test>().ToPageList(20, 50, ref total);
     }
 }
Exemple #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);
        }
Exemple #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();
     }
 }
Exemple #7
0
 public static void ReadData()
 {
     ODAContext ctx  = DBConfig.GetODAContext();
     var        t    = ctx.GetCmd <CmdTest>();
     var        list = t.SelectM();
 }
Exemple #8
0
 public static void GetById()
 {
     ODAContext ctx  = DBConfig.GetODAContext();
     var        t    = ctx.GetCmd <CmdTest>();
     var        list = t.Where(t.ColId == 1).SelectM();
 }