dblayer,我最近开源的数据库轻量级orm框架,目前支持sqlserver、mysql、oracle, 特别做了分页的封装。
这个框架从七八年前开始逐渐升级而来,也经历了不少项目,希望可以将大家从sql字符串中解放出来。
开源地址
访问代码案例
var id = TheService.InsertEntity<syslog>( () => new SysLog() { LogId = -1, LogContentJson = "测试", LogCreater = "测试", LogCreateTime = DateTime.Now, LogType = "1"});</syslog>
分页操作
/// <summary>/// 分页查询/// </summary>/// <param>查询条件/// <returns></returns>public IEnumerable<sysuser> Seach(SysUserCondition.Search condition) {var page = new Pager<sysusercondition.search>() { Condition = condition, Table = "sys_user", Key = "user_id", Order = string.Empty, Field = "*", WhereAction = (Condition, Where, Paramters) =>{if (!string.IsNullOrEmpty(Condition.UserName)) { Where.Append("AND user_name LIKE @user_name "); Paramters.Add(base.CreateParameter("@user_name", string.Concat("%", Condition.UserName, "%"))); }if (!string.IsNullOrEmpty(Condition.UserEmail)) { Where.Append("AND user_email LIKE @user_email "); Paramters.Add(base.CreateParameter("@user_email", string.Concat("%", Condition.UserEmail, "%"))); }if (!string.IsNullOrEmpty(Condition.UserMobile)) { Where.Append("AND user_mobile LIKE @user_mobile "); Paramters.Add(base.CreateParameter("@user_mobile", string.Concat("%", Condition.UserMobile, "%"))); } } };var result = base.GetResultByPager<sysuser>(page);return result; }</sysuser></sysusercondition.search></sysuser>
推荐和spring 配合使用,具体配置代码请进入源码查看。
同时在spring 配置多个数据库连接,支持数据库连接字符串密码加密。只需要在 passwordKey加入密钥
<object> <property> <name-values> <add></add> <add></add> <add></add> <add></add> <add></add> </name-values> </property> <property></property> </object>
数据库唯一标识除了可以数据自动编码,还支持在代码端自动 生成 GUID 和 时间点。下面代码是uuid,时间点并按照顺序生成的自动编号
<object> <!--workerId:区域(机房):3 bits--> <constructor-arg></constructor-arg> <!--regionId:机器编号:10 bits--> <constructor-arg></constructor-arg> <!--twepoch:基准时间:Thu, 04 Nov 2010 01:42:54 GMT--> <!--(long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds--> <constructor-arg></constructor-arg> </object>
以上就是最新开源DBLayer的详细介绍的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号