public static void 简单查询() { List <SODUser> result = null; //方式 params SODUser user = new SODUser() { LogName = "zhang san" }; OQL q = OQL.From(user) .Select() .Where(user.LogName) .END; result = EntityQuery <SODUser> .QueryList(q); //方式 OQLCompare SODUser user2 = new SODUser(); OQL q2 = OQL.From(user2); OQLCompare oqlCompare = new OQLCompare(q2); oqlCompare.Comparer(user2.ID, ">", 0); //OQLCompare oqlCompare2 = new OQLCompare(user2).Comparer(user2.ID, OQLCompare.CompareType.Greater, 0); //q2 = q2.Select().Where(oqlCompare2).END; q2 = q2.Select().Where(oqlCompare).END; result = EntityQuery <SODUser> .QueryList(q2); }
public static void 更新() { SODUser user = new SODUser(); OQL q = OQL.From(user) .Select() .Where(cmp => cmp.Property(user.ID) == 4) .END; SODUser updateUser = EntityQuery <SODUser> .QueryObject(q); updateUser.LogPwd = "111111111"; //方式一 int result = EntityQuery <SODUser> .Instance.Update(updateUser); ////方式二 //EntityQuery<SODUser> eq = new EntityQuery<SODUser>(user); // result= eq.SaveAllChanges(); //方式三 updateUser.LogPwd = "aaaaaaaa"; OQL q2 = new OQL(updateUser); q2.Update(updateUser.LogPwd).Where(updateUser.ID); //结果大于0就成功 result = EntityQuery <SODUser> .Instance.ExecuteOql(q2); }
public static void 连表查询in() { SODUser user = new SODUser(); OQL q = new OQL(user); OQLCompareFunc resultFunc = cmp => { OQLCompare resultCmp = cmp.Comparer(user.ID, ">", 2); resultCmp = resultCmp & cmp.Comparer(user.LogName, "like", "%zhang%"); return(resultCmp); }; q.Select(user.ID).Where(resultFunc); SODUserRemark userRemark = new SODUserRemark(); OQL r = new OQL(userRemark); OQLCompareFunc resultFunc2 = cmp => { OQLCompare resultCmp = cmp.Comparer(userRemark.UserId, "IN", q); return(resultCmp); }; r.Select().Where(resultFunc2).OrderBy(userRemark.ID, "desc"); var outlist = EntityQuery <SODUserRemark> .QueryList(r); }
public static void 除() { SODUser user = new SODUser(); OQL q = OQL.From(user).Delete().Where(c => c.Comparer(user.ID, ">", 5)).END; int result = EntityQuery <SODUser> .Instance.ExecuteOql(q); 获取执行结果日志(); }
public static void 增加数据2() { SODUser user = new SODUser() { LogName = "wangfeng2", UserName = "******", Mobile = "13888888888" }; EntityQuery <SODUser> .Instance.Insert(user); }
public static void 增加数据1() { LocalDbContext context = new LocalDbContext(); SODUser zhang_san = new SODUser() { LogName = "zhang san", LogPwd = "123" }; int count = context.Add <SODUser>(zhang_san);//采用 DbContext 方式插入数据 获取执行结果日志(); }
public void 序列号() { SODUser model = new SODUser(); model.LogName = "aa"; //序列化 byte[] buffer = PdfNetSerialize.BinarySerialize(model); string tempString = Convert.ToBase64String(buffer); //反序列化(为实现) byte[] buffer2 = Convert.FromBase64String(tempString); SODUser customer2 = (SODUser)PdfNetSerialize.BinaryDeserialize(buffer2, typeof(SODUser)); }
public static void 杂查询() { SODUser user = new SODUser(); OQL q = OQL.From(user) .Select() .Where(cmp => cmp.Property(user.LogName) == "zhangyi" & cmp.Comparer(user.ID, "like", 1)) .END; List <SODUser> users = EntityQuery <SODUser> .QueryList(q); string sql = q.ToString(); sql = q.PrintParameterInfo(); }
/// <summary> /// 简单查询 /// </summary> /// <returns></returns> public List <SODUser> getRegionList(string logName) { var outlist = new List <SODUser>(); try { SODUser model = new SODUser() { LogName = logName }; OQL q = new OQL(model); q.Select().Where(model.LogName); outlist = new EntityQuery <SODUser>(CurrentDataBase).GetList(q); } catch (Exception ex) { throw ex; } return(outlist); }
public static void 分页查询() { SODUser user = new SODUser(); OQL q = new OQL(user); OQLCompareFunc resultFunc = cmp => { OQLCompare resultCmp = cmp.Comparer(user.ID, ">", 0); resultCmp = resultCmp & cmp.Comparer(user.LogName, "like", "%zhang%"); return(resultCmp); }; q.Select().Where(resultFunc).OrderBy(user.ID); //分页 q.PageEnable = true; q.PageWithAllRecordCount = 10; q.Limit(10, 1, true); var outlist = EntityQuery <SODUser> .QueryList(q); int pageCount = q.PageWithAllRecordCount; }