by kevin
  
    8.   
      十月 2015 14:42
  >
  
  
  
FlentData3.0.1 好像不支持,或者是我没找到使用的方法,3.0.1支持。  代码:  new DbContext().ConnectionStringName(@"default", new OracleProvider());
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpco... 
[更多...] 
  
  by kevin
  
    27.   
      九月 2013 13:46
  >
  
  
  
FluentData是一个微型的ORM框架,使用可以很容易的对数据库进行数据操作。前段时间,花了点时间,对FluentData3.0的使用手册做了翻译,求点评。  FluentData入门(一)--核心概念  FluentData入门(二)--创建DbContext  FluentData入门(三)—Query  FluentData入门(四)—Mapping  FluentData入门(五)—Insert, Update, Delete  FluentData入门(六)--存储过程和事务
  
  
 
  
  by kevin
  
    23.   
      九月 2013 13:44
  >
  
  
  
存储过程  使用SQL语句:              1: var rowsAffected = Context.Sql("ProductUpdate") 
       2:             .CommandType(DbCommandTypes.StoredProcedure) 
       3:             .Parameter("ProductId", 1) 
       4:             .Parameter("Name", "The Warren Buffet Way") 
       5:             .Execute(); 
使用builder: 
  
       1: va... 
[更多...] 
  
  by kevin
  
    17.   
      九月 2013 13:26
  >
  
  
  
插入数据    使用 SQL 语句:             1: int productId = Context.Sql(@"insert into Product(Name, CategoryId)
       2:             values(@0, @1);")
       3:             .Parameters("The Warren Buffet Way", 1)
       4:             .ExecuteReturnLastId<int>(); 
使用builder:
  
       1: int productId = Context.Insert("Product")
       2:... 
[更多...] 
  
  by kevin
  
    13.   
      九月 2013 17:55
  >
  
  
  
映射    自动映射 – 在数据库对象和.Net object自动进行1:1匹配                  1: List<Product> products = Context.Sql(@"select *
       2:             from Product")
       3:             .QueryMany<Product>(); 
自动映射到一个自定义的Collection: 
  
  
       1: ProductionCollection products = Context.Sql("select * from Product").QueryMany<Product, ProductionCollection&... 
[更多...] 
  
  by kevin
  
    13.   
      九月 2013 16:08
  >
  
  
  
查询一组数据    返回一组dynamic对象(new in .NET 4.0)             1: List<dynamic> products = Context.Sql("select * from Product").QueryMany<dynamic>(); 
返回一组强类型对象
  
       1: List<Product> products = Context.Sql("select * from Product").QueryMany<Product>(); 
返回一个自定义的Collection
  
       1: ProductionCollection products = Context.Sql("... 
[更多...] 
  
  by kevin
  
    7.   
      九月 2013 13:58
  >
  
  
  
如何创建和初始化一个DbContext   可以在*.config文件中配置connection string,将connection string name或者将整个connection string 作为参数传递给DbContext来创建DbContext。  重要配置   IgnoreIfAutoMapFails – IDbContext.IgnoreIfAutoMapFails返回一个IDbContext,该实例中,如果自动映射失败时是否抛出异常  通过*.config中配置的ConnectionStringName创建一个DbContext             1: public IDbContext Context()
       2: {
       3:     return new DbContext().ConnectionStringNam... 
[更多...] 
  
  by kevin
  
    7.   
      九月 2013 13:17
  >
  
  
  
DbContext类  这是FluentData的核心类,可以通过配置ConnectionString来定义这个类,如何连接数据库和对具体的哪个数据库进行数据查询操作。         DbCommand类  这个类负责在相对应的数据库执行具体的每一个数据操作。         Events     DbContext类定义了以下这些事件:     OnConnectionClosed     OnConnectionOpened     OnConnectionOpening     OnError     OnExecuted     OnExecuting    可以在事件中,记录每个SQL查询错误或者SQL查询执行的 时间等信息。   Builders     Builder用来创建Insert, Update, Delete等相关的DbCommand实例。  Mappi... 
[更多...] 
  
  by kevin
  
    4.   
      六月 2013 21:42
  >
  
  
  
现在开发的项目中使用fluentdata进行数据访问,简单易用,但是,也是有坑爹的bug。  先记录2个:  1 IStoredProcedureBuilderDynamic StoredProcedure(string storedProcedureName, ExpandoObject item) 参数类型明明是ExpandoObject,还是需要做一次显示转换。  A.  Bad             1: var command = DefaultContext.StoredProcedure("InsertSPName", Entity)
       2:                     .AutoMap().ParameterOut("EntityId", DataTypes.Int32, 4);
... 
[更多...]