Esempio n. 1
0
        static void Main1(string[] args)
        {
            //GlobalConfig.UseDb(ProviderType.MySql);

            SqlLam <User> sql = new SqlLam <User>("u");

            sql.Select(m => new { m.F_Account, m.F_Birthday });
            //sql.Where(m => m.F_CreatorTime == DateTime.Now || m.F_DepartmentId == "aaa");
            ////sql.And(m => m.F_DeleteUserId == "a");
            sql.And().Begin();
            sql.Or(m => m.F_Description == "bbb");
            sql.Or(m => m.F_DutyId == "333");
            sql.End();
            //sql.Select(m => m.F_SecurityLevel, m => m.F_RoleId).GroupBy(m => m.F_NickName);
            //sql.Where(m => m.F_RoleId == "a").OrderBy(m => m.Id);
            //sql.Delete(m => m.Id == 1);
            //sql.Truncate();// 有问题
            int age = 10;

            UserLogon ul = new UserLogon();

            ul.F_Language = age.ToString();

            User u = new User();

            u.Id        = 1;
            u.Name      = "roc";
            u.F_Account = "不知道";

            //sql.Select(m => new { m.F_Account, m.Name, m.F_WeChat });
            //sql.Where(m => m.F_LastModifyTime == DateTime.Now.AddDays(3));
            //sql.Delete().Join<UserLogon>((a, b) => a.F_Id == u.Name, aliasName: "ul").Where(m => m.F_UserId == u.F_Account);
            //sql.Where(m => m.Id == 1);

            //sql.Update(u, m => new { m.F_Account, m.F_RoleId }).Join<UserLogon>((a, b) => a.F_Id == u.Name, aliasName: "ul").Where(m => m.F_UserId == u.F_Account);
            //sql.Where(m => m.Id == 1);

            List <User> areas = new List <User>();

            areas.Add(new User()
            {
                F_Id = "1"
            });
            areas.Add(new User()
            {
                F_CreatorTime = DateTime.Now
            });

            //User[] us = new User[] { };
            //sql.Insert(areas, m => new { m.Id, m.Name, m.F_WeChat });
            //sql.Insert(areas, m => new { m.F_WeChat, m.Name, m.F_SortCode });
            //sql.Insert(new { Id = 1, Name = "Roc" }, increment: true);

            //SqlLam<UserLogon> sqlUl = new SqlLam<UserLogon>("ul");
            //sqlUl.Select(m => new { F_WeChat = m.F_UserId, Name = m.F_Theme, F_SortCode = m.F_Question }).Where(m => m.F_UserId == "aa");

            //sql.InsertWithQuery(m => new { m.F_WeChat, m.Name, m.F_SortCode }, sqlUl);

            string sqlString = sql.GetSql();

            Console.WriteLine(string.Format("SQL: {0}", sqlString));
            var ps = sql.GetParameters();

            foreach (var item in ps)
            {
                Console.WriteLine(string.Format("Key: {0}, Value: {1}", item.Key, item.Value));
            }

            Console.Read();
        }