关于Farseer.Net V1.0 概念版本的消息

V0.2版的开源距离今天(05年03月)已有近3年的时间。可以说这个版本已经有点落伍的感觉了,呵呵。

V0.2版至今一直处于BUG的修复及一些细小功能的增加,所以版本号上一直没有变化。

其实在这1、2年中,我一直在想着Farseer.Net 的未来发展状况。有尝试用EF的核心、也有想过用NHibernate的核心。仅仅是在这些核心的基础下做二次开发,以个人编码的经验从客户端调用角度进行“优化”,但总是感觉缺少点什么?没错,就是缺少研发精神,缺少属于Farseer.Net独特的一面,有种寄人(第三方框架)篱下的感觉。所以决定还是完全采用自己的编码吧。当然在一些处理手法上,也会尝试去学习他们的优点。

V1.0目标

本次V1.0的升级,是一个质的改变,(尽可能不改变客户端调用)

  1. 完全重写内核代码(FS.Core);
  2. 以面向接口的设计模式进行编写。
  3. 实现批量SQL的传输(相对V0.2,是每一条SQL就与数据库交互的)。
  4. 实现延迟加载。
  5. 内置内存数据库。(有时候为了做一些小尝试,没必要去专门创建一个数据库,或者无法联网的情况下)
  6. 考虑到可能有些人只用到本框架ORM部份,因此非必要的代码,独立为一个类库,按实现需要附加。
  7. 分离表、存储过程、视图。
  8. Farseer.Net未提供到的一些SQL高级运用,支持自定义SQL。
  9. 更易于扩展新的SQL的方法。(比如V0.2中,GroupBy/Join是未支持的。需要支持的话,对于V0.2来说,是比较困难的(维护))。
  10. 提供与V0.2方式一样的数据访问以外,增加数据仓库的方式。第三条说到的批量SQL,是将执行中的SQL,加到组队列中(SQL被暂存到每个队列中,来等待被执行)

这10条中的每一条要实现都是比较困难的,暂时计划是2015年4月初有一个比较完整的版本出来。

不了解Farseer.Net 的朋友,可以看看V0.2的教程。其实目前优秀的ORM框架不胜其数,Farseer.Net开源仅是为了让大家学习了解一般的ORM框架的实现。从中希望大家对里在面代码不科学地方,多提出来。让大家一同进步。

开源地址:GitHub

下面,放上目前框架中片断代码,有兴趣的朋友,可以到GitHub处下载。目前框架完全托管在GitHub中。并且我将每天进行不间断的更新。

GitHub地址:https://github.com/steden/Farseer.net  有两个分支,一个是:master、一个是Concept。需要关注V1.0的动向、进度,需要切换到:Concept分支中来。

代码片断

 1 using System;
 2 using FS.Configs;
 3 using FS.Core.Data;
 4
 5 namespace FS.Core.Context
 6 {
 7     /// <summary>
 8     /// 表上下文
 9     /// </summary>
10     public class TableContext : IDisposable
11     {
12         /// <summary>
13         /// 通过数据库配置,连接数据库
14         /// </summary>
15         /// <param name="dbIndex">数据库选项</param>
16         /// <param name="tableName">表名称</param>
17         protected internal TableContext(int dbIndex = 0, string tableName = null) : this(DbFactory.CreateConnString(dbIndex), DbConfigs.ConfigInfo.DbList[dbIndex].DataType, DbConfigs.ConfigInfo.DbList[dbIndex].CommandTimeout, tableName) { }
18
19         /// <summary>
20         /// 通过自定义数据链接符,连接数据库
21         /// </summary>
22         /// <param name="connectionString">数据库连接字符串</param>
23         /// <param name="dbType">数据库类型</param>
24         /// <param name="commandTimeout">SQL执行超时时间</param>
25         /// <param name="tableName">表名称</param>
26         protected internal TableContext(string connectionString, DataBaseType dbType = DataBaseType.SqlServer, int commandTimeout = 30, string tableName = null) : this(new DbExecutor(connectionString, dbType, commandTimeout), tableName) { }
27
28         /// <summary>
29         /// 事务
30         /// </summary>
31         /// <param name="database">数据库执行</param>
32         /// <param name="tableName">表名称</param>
33         protected internal TableContext(DbExecutor database, string tableName = null)
34         {
35             Database = database;
36             TableName = tableName;
37             IsMergeCommand = true;
38         }
39
40         /// <summary>
41         /// 数据库
42         /// </summary>
43         internal protected DbExecutor Database { get; private set; }
44
45         /// <summary>
46         /// 合并执行命令
47         /// </summary>
48         internal protected bool IsMergeCommand { get; set; }
49
50         /// <summary>
51         /// 表名
52         /// </summary>
53         internal protected string TableName { get; protected set; }
54
55         /// <summary>
56         /// 保存修改
57         /// IsMergeCommand=true时:只提交一次SQL到数据库
58         /// </summary>
59         public int SaveChanges()
60         {
61             return -1;
62         }
63
64         /// <summary>
65         /// 释放资源
66         /// </summary>
67         public void Dispose()
68         {
69             Database.Dispose();
70             Database = null;
71         }
72     }
73 }
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq.Expressions;
 4 using FS.Core.Infrastructure;
 5
 6 namespace FS.Core.Context
 7 {
 8     public class TableSet<TEntity> : IDisposable where TEntity : class, new()
 9     {
10         /// <summary>
11         /// 数据库上下文
12         /// </summary>
13         private TableContext<TEntity> _dbContext;
14
15         /// <summary>
16         /// 禁止外部实例化
17         /// </summary>
18         private TableSet() { }
19
20         internal TableSet(TableContext<TEntity> dbContext) : this()
21         {
22             _dbContext = dbContext;
23             QueryProvider = DbFactory.CreateQuery(_dbContext);
24         }
25
26         /// <summary>
27         /// 数据库查询支持
28         /// </summary>
29         private IQuery QueryProvider { get; set; }
30
31         /// <summary>
32         ///     字段选择器
33         /// </summary>
34         /// <param name="select">字段选择器</param>
35         public TableSet<TEntity> Select<T>(Expression<Func<TEntity, T>> select)
36         {
37             //QueryProvider.QueryQueue.ExpSelect = QueryProvider.QueryQueue.ExpSelect == null ? QueryProvider.QueryQueue.ExpSelect = select : Expression.Add(QueryProvider.QueryQueue.ExpSelect, select);
38             return this;
39         }
40
41         /// <summary>
42         ///     查询条件
43         /// </summary>
44         /// <param name="where">查询条件</param>
45         public TableSet<TEntity> Where(Expression<Func<TEntity, bool>> where)
46         {
47             //QueryProvider.QueryQueue.ExpWhere = QueryProvider.QueryQueue.ExpWhere == null ? QueryProvider.QueryQueue.ExpWhere = where : Expression.Add(QueryProvider.QueryQueue.ExpWhere, where);
48             return this;
49         }
50
51         public TableSet<TEntity> Desc<TKey>(Expression<Func<TEntity, TKey>> desc)
52         {
53             //QueryProvider.QueryQueue.ExpOrderBy = QueryProvider.QueryQueue.ExpOrderBy == null ? QueryProvider.QueryQueue.ExpOrderBy = desc : Expression.Add(QueryProvider.QueryQueue.ExpOrderBy, desc);
54             return this;
55         }
56
57         public TableSet<TEntity> Asc<TKey>(Expression<Func<TEntity, TKey>> asc)
58         {
59             //QueryProvider.QueryQueue.ExpOrderBy = QueryProvider.QueryQueue.ExpOrderBy == null ? QueryProvider.QueryQueue.ExpOrderBy = asc : Expression.Add(QueryProvider.QueryQueue.ExpOrderBy, asc);
60             return this;
61         }
62         public List<TEntity> ToList()
63         {
64             return QueryProvider.QueryQueue.List.Query<TEntity>();
65         }
66
67         public TEntity ToInfo()
68         {
69             return QueryProvider.QueryQueue.Info.Query<TEntity>();
70         }
71
72         public TEntity Update(TEntity entity)
73         {
74             QueryProvider.QueryQueue.Update.Query(entity);
75             return entity;
76         }
77
78         public int Delete()
79         {
80             return QueryProvider.QueryQueue.Delete.Query<TEntity>();
81         }
82
83         public TEntity Insert(TEntity entity)
84         {
85             QueryProvider.QueryQueue.Insert.Query(entity);
86             return entity;
87         }
88
89         public void Dispose()
90         {
91             throw new NotImplementedException();
92         }
93     }
94 }
 1 using System.Collections.Generic;
 2 using FS.Core.Context;
 3 using FS.Core.Infrastructure;
 4
 5 namespace FS.Core.Client.SqlServer
 6 {
 7     public class SqlServerQuery : IQuery
 8     {
 9         /// <summary>
10         /// 组列表
11         /// </summary>
12         private List<IQueryQueue> GroupQueryQueueList { get; set; }
13
14         public SqlServerQuery(TableContext tableContext)
15         {
16             TableContext = tableContext;
17             Init();
18         }
19
20         public TableContext TableContext { get; private set; }
21         public IQueryQueue QueryQueue { get; set; }
22
23         public void Execute()
24         {
25             GroupQueryQueueList.Add(QueryQueue);
26             Init();
27         }
28
29         public void Init()
30         {
31             QueryQueue = new SqlServerQueryQueue(this);
32             if (GroupQueryQueueList == null) { GroupQueryQueueList = new List<IQueryQueue>(); }
33         }
34     }
35 }
 1 using System.Linq.Expressions;
 2 using System.Text;
 3 using FS.Core.Client.SqlServer.Query;
 4 using FS.Core.Infrastructure;
 5 using FS.Core.Infrastructure.Query;
 6
 7 namespace FS.Core.Client.SqlServer
 8 {
 9     public class SqlServerQueryQueue : IQueryQueue
10     {
11         private readonly IQuery _queryProvider;
12         public Expression ExpOrderBy { get; set; }
13         public Expression ExpSelect { get; set; }
14         public Expression ExpWhere { get; set; }
15         public StringBuilder Sql { get; set; }
16         public SqlServerQueryQueue(IQuery queryProvider)
17         {
18             _queryProvider = queryProvider;
19         }
20
21         private IQueryQueueList _list;
22         public IQueryQueueList List { get { return _list ?? (_list = new SqlServerQueryList(_queryProvider)); } }
23
24
25         private IQueryQueueInfo _info;
26         public IQueryQueueInfo Info { get { return _info ?? (_info = new SqlServerQueryInfo(_queryProvider)); } }
27
28
29         private IQueryQueueInsert _insert;
30         public IQueryQueueInsert Insert { get { return _insert ?? (_insert = new SqlServerQueryInsert(_queryProvider)); } }
31
32
33         private IQueryQueueUpdate _update;
34         public IQueryQueueUpdate Update { get { return _update ?? (_update = new SqlServerQueryUpdate(_queryProvider)); } }
35
36
37         private IQueryQueueDelete _delete;
38         public IQueryQueueDelete Delete { get { return _delete ?? (_delete = new SqlServerQueryDelete(_queryProvider)); } }
39
40         public void Dispose()
41         {
42             Sql.Clear();
43             ExpOrderBy = null;
44             ExpSelect = null;
45             ExpWhere = null;
46             Sql = null;
47             _list = null;
48             _info = null;
49             _insert = null;
50             _update = null;
51             _delete = null;
52         }
53     }
54 }

可能当你看到以上代码时,已经是陈旧了。关注最新代码,请到GitHub中。

客户端调用

 1             using (var context = new TableContext<UserPO>())
 2             {
 3                 var info = context.TableSet.Where(o => o.ID > 0).Desc(o => new { o.ID, o.LoginCount }).Asc(o => o.GenderType).ToInfo();
 4                 info.PassWord = "123456";
 5
 6                 context.TableSet.Update(info);
 7                 context.TableSet.Insert(info);
 8
 9
10                 var lst = context.TableSet.Where(o => o.ID > 0).Desc(o => new { o.ID, o.LoginCount }).Asc(o => o.GenderType).ToList();
11
12                 context.SaveChanges();
13             }

1 TableContext<UserPO>.Data.Select(o => o.ID).Where(o => o.ID > 0).ToList();

基地交流

QQ群:116228666 (Farseer.net开源框架交流) 请注明:Farseer.Net

时间: 2024-08-10 14:23:04

关于Farseer.Net V1.0 概念版本的消息的相关文章

AEAI EM费用管理系统V1.0.2版本开源发布

本次开源发布是AEAI EM费用管理系统 V1.0.2版,该版本是此产品的首个版本,产品现已开源并上传至开源社区http://www.oschina.net/p/aeai-em. 产品说明: AEAI EM费用管理系统是数通畅联软件自主开发的一款费用报销管理软件,该系统主要是对企业报销事宜进行管理,包括一些核心的财务报销业务功能,例如项目配置.出差报销.流程审批.费用报销等功能模块,用来帮助企业管理日常.差旅所产生的一系列费用,并有效的提高企业费用报销的管理效率.AEAI EM费用管理系统内部已

hasura graphql-engine v1.0.0-alpha26 版本新功能试用

hasura graphql-engine v1.0.0-alpha26 已经发布了,有好多新的变动,测试使用docker 环境,同时pg 数据库使用了citus citus 是一个方便扩展的pg 数据库扩展解决方案,很不错. 环境准备 docker-compose && citus docker-compose 文件 version: '2.1' services: graphql-engine: image: hasura/graphql-engine:v1.0.0-alpha26 p

PHPRAP v1.0.8 版本发布,安装时数据库不存在自动创建

PHPRAP,是一个PHP轻量级开源API接口文档管理系统,致力于减少前后端沟通成本,提高团队协作开发效率,打造PHP版的RAP. PHPRAP已被评选为码云最有价值开源项目 更新记录 [修复]修复在虚拟主机下安装失败的BUG [修复]修复程序异常时页面空白的BUG [修复]修复上传建表sql文件时初始进度百分比错误的BUG [优化]安装步骤二中数据库名不存在自动创建 [新增]管理后台新增是否开启登录和注册验证码开关 [新增]安装步骤一中新增curl扩展是否安装的检测 特性 部署简单 提供傻瓜式

促进客户转化,提高客单价!酷客多小程序发布版本V1.0.9!

商户和企业主的又一次福音!酷客多小程序新零售o2o商城系统酷爱用户,为了追求极致的用户体验,没日没夜地沉浸于新功能的开发,经过一番努力,新功能终于上线啦! 此次版本迭代,在原有功能基础上做了大幅提升,板块明了,操作简单.这次功能,知道你们都很着急,闲话不说,咱们,开八! 此次版本主要新增了新增优惠券.模板切换.营销插件快捷入口三个模块 1.优惠券 通过前台页面点击进入到“领券中心”,就会出现领券中心的页面,领取相关优惠券. 新增优惠券模板,可以促进客户转化,轻松提高客单价 在这里可以对优惠券进行

AEAI CRM客户关系管理V1.0.3版发版说明

AEAI CRM客户管理系统包括一些核心的客户关系管理业务功能,如:潜在客户.线索管理.客户管理.拜访管理.商机管理.订单管理等模块,满足企业客户关系信息化的基本要求,并帮助企业提高客户资源的管理效率.本次发版的AEAI CRM客户关系管理为v1.0.3版本,该产品现已开源并上传至开源中国,产品下载地址:http://pan.baidu.com/s/1mgIdzGc ,欢迎大家下载使用,也可以加入数通畅联产品QQ技术群 299719834或关注"数通畅联"微信公众号,一起参与讨论. 官

wzplayer for ios 针对(mms)优化版本V1.0

wzplayer for ios针对mms优化版本发布. 1.支持mms,http,rtmp,rtsp等协议 2.支持全格式 下载地址:http://www.coolradio.cn/WzPlayer.ipa 更强大的,请使用tlplayerhttp://blog.csdn.net/tigerleap/article/details/19007057 联系方式:[email protected] QQ:514540005 版权所有,禁止转载. 发布自:http://blog.csdn.net/t

主流区块链技术特点及Fabric V0.6&V1.0版本特点

声明:文章内容来源于网络. 一.主流区块链技术特点 二.Hyperledger的fabric V0.6总体架构: 对应的0.6版本的运行时架构: 0.6版本的架构特点是: 结构简单: 应用-成员管理-Peer的三角形关系,主要业务功能全部集中于Peer节点:    架构问题:由于peer节点承担了太多的功能,所以带来扩展性.可维护性.安全性.业务隔离等方面的诸多问题,所以0.6版本在推出后,并没有大规模被行业使用,只是在一些零星的案例中进行业务验证: 三.Hyperledger的fabric V

C#写爬虫,版本V1.0

之前看了Sql Server中的基本数据类型,发现image这个类型还是比较特殊的. 于是乎就做了一个将图片以二进制流形式存储的程序http://www.cnblogs.com/JsonZhangAA/p/5568575.html,现在如果我想批量ed存储网上一个网站的图片,难道我要手写n多地址吗?显然这是不可取的,针对这种情况,就用C#写了一个简单的爬虫,我们所爬的对象是天文网http://www.tianwenwang.cn/ 程序的原理是利用WebRequest和WebResponse来相

江中微型统计分析软件V1.0版本完成

中文名称:江中微型统计分析软件 英文名称: 项目名称:JXUTCMMSAS 项目地址:保密 在研究生最后历时1年的时间里,完成了江中微型统计分析软件V1.0,后续还在不断更新中,将自己的改进算法.机器学习中的常用算法全部集成到该软件中,并通过对外提供调用接口,提供可视化界面,立志让其成为一款普通人可用.机器学习算法研究者调用的软件,让算法研究者们,不需要再重新做重复工作,着眼于算法本身,在已有基础上研究. 1.开发环境 MCR——项目中调用到MATLAB2014A(32bite)的MCR环境的j