The Back-end for Front-end Pattern (BFF)
The Back-end for Front-end Pattern (BFF)
When I was at SoundCloud, being transparent about our architecture
evolution was part of our technology strategy. Something we’ve
talked about on countless occasions but never really described in
detail was our application of the Back-end for Frontend architecture pattern, or BFF. This post documents my
understanding of how we developed and applied this technique.
ORM及代码生成器C#源码(2012最新版Kenly.DBFramework4.6.5.5)
对象关系映射架构(DBFramework)及代码生成器源码
一、使用对象关系映射组件Kenly.DBFramework.dll不用编写任何SQL或者存储过程即可实现下列功能:
1、数据表、视图和存储过程与对象之间的转换。
2、数据表、视图的自定义条件查询。
3、数据表、视图的分页查询。
4、根据ID、主键或自定义条件对数据表进行增、删、改操作。
5、实现一对一、一对多、多对一和多对多的关系映射。
6、支持单个对象和多个对象之间的事务控制。
7、支持查询结果排序。
8、支持查询表达式生成。
9、支持延迟加载。
二、代码生成器
1、根据指定的数据库连接,自动生成数据表、视图和存储过程对应的对象代码(C#代码)。
2、自动生成相关的工程文件,生成完整的业务层项目文件。
3、可以帮助生成自定义查询方法。
4、支持SQLServer2000、SQLServer2005和Oracle代码生成插件,支持插件扩展。
提供
1、对象关系映射组件: Kenly.DBFramework.dll
2、代码生成器源码:CodeHelper。
3、代码生成器插件源码(支持SQLServer2000、SQLServer2005和Oracle):Plugin。
4、使用手册:DBFramework.Manual V4.5.3.pdf。
主要API:
public abstract class ViewGateway where T: new()
{
// Methods
static ViewGateway();
protected ViewGateway();
protected static int Count();
protected static int Count(string condition);
protected static List CountGroup(string groupBy);
protected static List CountGroup(string condition, string groupBy);
public static List CreateInstances(int count);
protected static List Distinct(string columnName);
protected static List Distinct(string columnName, string condition);
protected static List Distinct(string columnName, string condition, bool ignoreNull);
protected static bool Exists(string condition);
public bool ExistsById();
public bool ExistsByPK();
protected static List Find(PagingArg pagingArg, params string[] propertyNames);
protected static List Find(string condition, params string[] propertyNames);
protected static List Find(PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static List Find(string condition, PagingArg pagingArg, params string[] propertyNames);
protected static List Find(string condition, PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static List FindAll(params string[] propertyNames);
protected static void FindTop(T firstOne);
protected static List FindTop(int topCount, params string[] propertyNames);
protected static void FindTop(string condition, T firstOne);
protected static List FindTop(string condition, int topCount, params string[] propertyNames);
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
protected void InitializeInstance(T entity);
protected static object Max(string columnName);
protected static object Max(string columnName, string condition);
protected static List MaxGroup(string columnName, string groupBy);
protected static List MaxGroup(string columnName, string condition, string groupBy);
protected static object Min(string columnName);
protected static object Min(string columnName, string condition);
protected static List MinGroup(string columnName, string groupBy);
protected static List MinGroup(string columnName, string condition, string groupBy);
protected static DataTable Query(PagingArg pagingArg, params string[] propertyNames);
protected static DataTable Query(string condition, params string[] propertyNames);
protected static DataTable Query(PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static DataTable Query(string condition, PagingArg pagingArg, params string[] propertyNames);
protected static DataTable Query(string condition, PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static DataTable QueryAll(params string[] propertyNames);
protected static DataTable QueryTop(int topCount, params string[] propertyNames);
protected static DataTable QueryTop(string condition, int topCount, params string[] propertyNames);
public ArrayList RetrieveAssociations();
public ArrayList RetrieveAssociations(Type elementType);
public ArrayList RetrieveAssociations(params Type[] elementTypes);
public void RetrieveById();
public void RetrieveByPK();
protected internal virtual void RetrieveBySql(string sql);
public void ShadowCopyTo(object targetEntity);
public void ShadowCopyTo(T targetEntity);
protected static double Sum(string columnName);
protected static double Sum(string columnName, string condition);
protected static List SumGroup(string columnName, string groupBy);
protected static List SumGroup(string columnName, string condition, string groupBy);
public static string ToColumnName(string propertyName);
public static T ToObject(DataRow adaptedRow);
public static List ToObjects(DataTable adaptedTable);
public static List ToObjects(DataRow[] adaptedRows);
public static string ToPropertyName(string columnName);
public static DataTable ToTable(IList entities);
public static DataTable ToTable(params T[] entities);
public static DataTable ToTable(bool isAdapted, params T[] entities);
public static DataTable ToTable(bool isAdapted, IList entities);
// Properties
protected internal static string CommandText { get; }
protected internal static GatewayConfig Config { get; }
internal T Entity { get; set; }
public object EntityId { get; }
public object PrimaryKey { get; }
protected static Order SortedOrder { get; set; }
}
public abstract class TableGateway : ViewGateway where T: TableGateway, new()
{
// Methods
static TableGateway();
protected TableGateway();
public int AddNew();
public static int AddNew(IList entities);
public static int AddNew(T entity);
public int AddNew(bool returnIdentity);
public static int AddNew(T entity, bool returnIdentity);
public static int AddNew(IList entities, out Transaction transaction);
public static int AddNew(IList entities, bool returnIdentity);
public static int AddNew(T entity, out Transaction transaction);
public static int AddNew(IList entities, bool returnIdentity, out Transaction transaction);
public static int AddNew(T entity, bool returnIdentity, out Transaction transaction);
public IDbTransaction BeginTransaction();
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel);
public IDbTransaction BeginTransaction(double activeTime);
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel, double activeTime);
public bool Commit();
protected static int Delete(string condition);
protected static int Delete(string condition, out Transaction transaction);
public int DeleteById();
public static int DeleteById(T entity);
public static int DeleteById(IList entities);
public static int DeleteById(IList entities, out Transaction transaction);
public static int DeleteById(T entity, out Transaction transaction);
public int DeleteByPK();
public static int DeleteByPK(T entity);
public static int DeleteByPK(IList entities);
public static int DeleteByPK(IList entities, out Transaction transaction);
public static int DeleteByPK(T entity, out Transaction transaction);
protected void OnPropertyChanged(MethodBase propertyMethod);
protected void OnPropertyChanged(string propertyName);
protected internal override void RetrieveBySql(string sql);
public bool Rollback();
protected static int Update(T entity, string condition);
protected static int Update(T entity, string condition, out Transaction transaction);
public int UpdateById();
public static int UpdateById(IList entities);
public static int UpdateById(T entity);
public static int UpdateById(T entity, out Transaction transaction);
public static int UpdateById(IList entities, out Transaction transaction);
public int UpdateByPK();
public static int UpdateByPK(IList entities);
public static int UpdateByPK(T entity);
public static int UpdateByPK(IList entities, out Transaction transaction);
public static int UpdateByPK(T entity, out Transaction transaction);
// Properties
public bool Changed { get; }
public List ChangedPropertyNames { get; }
}
public class StoredProcedure : IStoredProcedure
{
public bool BeginTransaction();
public void CloseReader(IDataReader reader);
public bool Commit();
public DataSet ExecuteDataSet();
public DataTable ExecuteDataTable();
public DataTable ExecuteDataTable();
public List ExecuteEntity();
public int ExecuteNonQuery();
public IDataReader ExecuteReader();
public object ExecuteScalar();
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
protected void InitializeInstance(T entity);
public bool Rollback();
}
public class AggregateEntity where T: AggregateEntity, new()
{
public static List Execute();
protected static List Execute(string condition);
public static DataTable ExecuteDataTable();
protected static DataTable ExecuteDataTable(string condition);
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
// Properties
protected static Order SortedOrder { get; set; }
}
public static class EntityMapper
{
// Methods
public static void AdaptToDatabase(DataTable adaptedTable);
public static void AdaptToEntity(DataTable rawTable);
public static void CopyToEntities(IList entities, IList adaptedRows);
public static void CopyToEntities(IList entities, DataTable adaptedTable);
public static void CopyToEntity(T entity, DataRow row);
public static List CreateEntities(int count);
public static DataTable CreateTable();
public static DataTable CreateTable(bool isAdapted);
public static string ToColumnName(string propertyName);
public static List ToEntities(IList adaptedRows);
public static List ToEntities(DataTable table);
public static T ToEntity(DataRow adaptedRow);
public static string ToPropertyName(string columnName);
public static DataTable ToTable(IList entities);
public static DataTable ToTable(params T[] entities);
public static DataTable ToTable(bool isAdapted, params T[] entities);
public static DataTable ToTable(bool isAdapted, IList entities);
}
public static class EntityUtility
{
// Methods
public static List Inherit(IList entities);
public static T Inherit(object entity);
public static T Inherit(Tbase baseEntity, TransformAction method);
public static List Inherit(IList baseEntities, TransformAction method);
public static void ShadowCopy(IList targetEntities, IList sourceEntities);
public static void ShadowCopy(object targetEntity, object sourceEntity);
}
SQL实例集锦(很实用)
SQL参考实例,函括数据查询、更新、删除等方面
C#面试宝典(常见考题集)
C#试题集,对学习提高C#知识或面试很有用。
ORM及代码生成器C#源码(最新版V4.5.8.5、非常适于ASP.NET MVC)
对象关系映射架构(DBFramework)及代码生成器源码
一、使用对象关系映射组件Kenly.DBFramework.dll不用编写任何SQL或者存储过程即可实现下列功能:
1、数据表、视图和存储过程与对象之间的转换。
2、数据表、视图的自定义条件查询。
3、数据表、视图的分页查询。
4、根据ID、主键或自定义条件对数据表进行增、删、改操作。
5、实现一对一、一对多、多对一和多对多的关系映射。
6、支持单个对象和多个对象之间的事务控制。
7、支持查询结果排序。
8、支持查询表达式生成。
9、支持延迟加载。
二、代码生成器
1、根据指定的数据库连接,自动生成数据表、视图和存储过程对应的对象代码(C#代码)。
2、自动生成相关的工程文件,生成完整的业务层项目文件。
3、可以帮助生成自定义查询方法。
4、支持SQLServer2000、SQLServer2005和Oracle代码生成插件,支持插件扩展。
提供
1、对象关系映射组件: Kenly.DBFramework.dll
2、代码生成器源码:CodeHelper。
3、代码生成器插件源码(支持SQLServer2000、SQLServer2005和Oracle):Plugin。
4、使用手册:DBFramework.Manual V4.5.3.pdf。
主要API:
public abstract class ViewGateway where T: new()
{
// Methods
static ViewGateway();
protected ViewGateway();
protected static int Count();
protected static int Count(string condition);
protected static List CountGroup(string groupBy);
protected static List CountGroup(string condition, string groupBy);
public static List CreateInstances(int count);
protected static List Distinct(string columnName);
protected static List Distinct(string columnName, string condition);
protected static List Distinct(string columnName, string condition, bool ignoreNull);
protected static bool Exists(string condition);
public bool ExistsById();
public bool ExistsByPK();
protected static List Find(PagingArg pagingArg, params string[] propertyNames);
protected static List Find(string condition, params string[] propertyNames);
protected static List Find(PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static List Find(string condition, PagingArg pagingArg, params string[] propertyNames);
protected static List Find(string condition, PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static List FindAll(params string[] propertyNames);
protected static void FindTop(T firstOne);
protected static List FindTop(int topCount, params string[] propertyNames);
protected static void FindTop(string condition, T firstOne);
protected static List FindTop(string condition, int topCount, params string[] propertyNames);
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
protected void InitializeInstance(T entity);
protected static object Max(string columnName);
protected static object Max(string columnName, string condition);
protected static List MaxGroup(string columnName, string groupBy);
protected static List MaxGroup(string columnName, string condition, string groupBy);
protected static object Min(string columnName);
protected static object Min(string columnName, string condition);
protected static List MinGroup(string columnName, string groupBy);
protected static List MinGroup(string columnName, string condition, string groupBy);
protected static DataTable Query(PagingArg pagingArg, params string[] propertyNames);
protected static DataTable Query(string condition, params string[] propertyNames);
protected static DataTable Query(PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static DataTable Query(string condition, PagingArg pagingArg, params string[] propertyNames);
protected static DataTable Query(string condition, PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static DataTable QueryAll(params string[] propertyNames);
protected static DataTable QueryTop(int topCount, params string[] propertyNames);
protected static DataTable QueryTop(string condition, int topCount, params string[] propertyNames);
public ArrayList RetrieveAssociations();
public ArrayList RetrieveAssociations(Type elementType);
public ArrayList RetrieveAssociations(params Type[] elementTypes);
public void RetrieveById();
public void RetrieveByPK();
protected internal virtual void RetrieveBySql(string sql);
public void ShadowCopyTo(object targetEntity);
public void ShadowCopyTo(T targetEntity);
protected static double Sum(string columnName);
protected static double Sum(string columnName, string condition);
protected static List SumGroup(string columnName, string groupBy);
protected static List SumGroup(string columnName, string condition, string groupBy);
public static string ToColumnName(string propertyName);
public static T ToObject(DataRow adaptedRow);
public static List ToObjects(DataTable adaptedTable);
public static List ToObjects(DataRow[] adaptedRows);
public static string ToPropertyName(string columnName);
public static DataTable ToTable(IList entities);
public static DataTable ToTable(params T[] entities);
public static DataTable ToTable(bool isAdapted, params T[] entities);
public static DataTable ToTable(bool isAdapted, IList entities);
// Properties
protected internal static string CommandText { get; }
protected internal static GatewayConfig Config { get; }
internal T Entity { get; set; }
public object EntityId { get; }
public object PrimaryKey { get; }
protected static Order SortedOrder { get; set; }
}
public abstract class TableGateway : ViewGateway where T: TableGateway, new()
{
// Methods
static TableGateway();
protected TableGateway();
public int AddNew();
public static int AddNew(IList entities);
public static int AddNew(T entity);
public int AddNew(bool returnIdentity);
public static int AddNew(T entity, bool returnIdentity);
public static int AddNew(IList entities, out Transaction transaction);
public static int AddNew(IList entities, bool returnIdentity);
public static int AddNew(T entity, out Transaction transaction);
public static int AddNew(IList entities, bool returnIdentity, out Transaction transaction);
public static int AddNew(T entity, bool returnIdentity, out Transaction transaction);
public IDbTransaction BeginTransaction();
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel);
public IDbTransaction BeginTransaction(double activeTime);
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel, double activeTime);
public bool Commit();
protected static int Delete(string condition);
protected static int Delete(string condition, out Transaction transaction);
public int DeleteById();
public static int DeleteById(T entity);
public static int DeleteById(IList entities);
public static int DeleteById(IList entities, out Transaction transaction);
public static int DeleteById(T entity, out Transaction transaction);
public int DeleteByPK();
public static int DeleteByPK(T entity);
public static int DeleteByPK(IList entities);
public static int DeleteByPK(IList entities, out Transaction transaction);
public static int DeleteByPK(T entity, out Transaction transaction);
protected void OnPropertyChanged(MethodBase propertyMethod);
protected void OnPropertyChanged(string propertyName);
protected internal override void RetrieveBySql(string sql);
public bool Rollback();
protected static int Update(T entity, string condition);
protected static int Update(T entity, string condition, out Transaction transaction);
public int UpdateById();
public static int UpdateById(IList entities);
public static int UpdateById(T entity);
public static int UpdateById(T entity, out Transaction transaction);
public static int UpdateById(IList entities, out Transaction transaction);
public int UpdateByPK();
public static int UpdateByPK(IList entities);
public static int UpdateByPK(T entity);
public static int UpdateByPK(IList entities, out Transaction transaction);
public static int UpdateByPK(T entity, out Transaction transaction);
// Properties
public bool Changed { get; }
public List ChangedPropertyNames { get; }
}
public class StoredProcedure : IStoredProcedure
{
public bool BeginTransaction();
public void CloseReader(IDataReader reader);
public bool Commit();
public DataSet ExecuteDataSet();
public DataTable ExecuteDataTable();
public DataTable ExecuteDataTable();
public List ExecuteEntity();
public int ExecuteNonQuery();
public IDataReader ExecuteReader();
public object ExecuteScalar();
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
protected void InitializeInstance(T entity);
public bool Rollback();
}
public class AggregateEntity where T: AggregateEntity, new()
{
public static List Execute();
protected static List Execute(string condition);
public static DataTable ExecuteDataTable();
protected static DataTable ExecuteDataTable(string condition);
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
// Properties
protected static Order SortedOrder { get; set; }
}
public static class EntityMapper
{
// Methods
public static void AdaptToDatabase(DataTable adaptedTable);
public static void AdaptToEntity(DataTable rawTable);
public static void CopyToEntities(IList entities, IList adaptedRows);
public static void CopyToEntities(IList entities, DataTable adaptedTable);
public static void CopyToEntity(T entity, DataRow row);
public static List CreateEntities(int count);
public static DataTable CreateTable();
public static DataTable CreateTable(bool isAdapted);
public static string ToColumnName(string propertyName);
public static List ToEntities(IList adaptedRows);
public static List ToEntities(DataTable table);
public static T ToEntity(DataRow adaptedRow);
public static string ToPropertyName(string columnName);
public static DataTable ToTable(IList entities);
public static DataTable ToTable(params T[] entities);
public static DataTable ToTable(bool isAdapted, params T[] entities);
public static DataTable ToTable(bool isAdapted, IList entities);
}
public static class EntityUtility
{
// Methods
public static List Inherit(IList entities);
public static T Inherit(object entity);
public static T Inherit(Tbase baseEntity, TransformAction method);
public static List Inherit(IList baseEntities, TransformAction method);
public static void ShadowCopy(IList targetEntities, IList sourceEntities);
public static void ShadowCopy(object targetEntity, object sourceEntity);
}
C#中文分词组件源码ChineseSegmentV1.0.3.0
中文分词是中文搜索引擎提高相关度非常关键的部分。用C#实现的中文分词组件,可以进行中文切词、词频统计、分词排名级别;支持XML词库、文本词库和二进制词库;可以往词库添加新词,过滤重复词,词库重新排序。
ORM及代码生成器和插件C#源码(DBFrameworkV4.5.3)
一、使用对象关系映射组件Kenly.DBFramework.dll不用编写任何SQL或者存储过程即可实现下列功能:
1、数据表、视图和存储过程与对象之间的转换。
2、数据表、视图的自定义条件查询。
3、数据表、视图的分页查询。
4、根据ID、主键或自定义条件对数据表进行增、删、改操作。
5、实现一对一、一对多、多对一和多对多的关系映射。
6、支持单个对象和多个对象之间的事务控制。
7、支持查询结果排序。
8、支持查询表达式生成。
9、支持延迟加载。
二、代码生成器
1、根据指定的数据库连接,自动生成数据表、视图和存储过程对应的对象代码(C#代码)。
2、自动生成相关的工程文件,生成完整的业务层项目文件。
3、可以帮助生成自定义查询方法。
4、支持SQLServer2000、SQLServer2005和Oracle代码生成插件,支持插件扩展。
提供
1、对象关系映射组件: Kenly.DBFramework.dll
2、代码生成器源码:Xsd2CS。
3、代码生成器插件源码(支持SQLServer2000、SQLServer2005和Oracle):Plugin。
4、使用手册:DBFramework.Manual V4.5.3.pdf。
主要API:
public abstract class ViewGateway<T> where T: new()
{
// Methods
static ViewGateway();
protected ViewGateway();
protected static int Count();
protected static int Count(string condition);
protected static List<int> CountGroup(string groupBy);
protected static List<int> CountGroup(string condition, string groupBy);
public static List<T> CreateInstances(int count);
protected static List<ColumnType> Distinct<ColumnType>(string columnName);
protected static List<ColumnType> Distinct<ColumnType>(string columnName, string condition);
protected static List<ColumnType> Distinct<ColumnType>(string columnName, string condition, bool ignoreNull);
protected static bool Exists(string condition);
public bool ExistsById();
public bool ExistsByPK();
protected static List<T> Find(PagingArg pagingArg, params string[] propertyNames);
protected static List<T> Find(string condition, params string[] propertyNames);
protected static List<T> Find(PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static List<T> Find(string condition, PagingArg pagingArg, params string[] propertyNames);
protected static List<T> Find(string condition, PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static List<T> FindAll(params string[] propertyNames);
protected static void FindTop(T firstOne);
protected static List<T> FindTop(int topCount, params string[] propertyNames);
protected static void FindTop(string condition, T firstOne);
protected static List<T> FindTop(string condition, int topCount, params string[] propertyNames);
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
protected void InitializeInstance(T entity);
protected static object Max(string columnName);
protected static object Max(string columnName, string condition);
protected static List<object> MaxGroup(string columnName, string groupBy);
protected static List<object> MaxGroup(string columnName, string condition, string groupBy);
protected static object Min(string columnName);
protected static object Min(string columnName, string condition);
protected static List<object> MinGroup(string columnName, string groupBy);
protected static List<object> MinGroup(string columnName, string condition, string groupBy);
protected static DataTable Query(PagingArg pagingArg, params string[] propertyNames);
protected static DataTable Query(string condition, params string[] propertyNames);
protected static DataTable Query(PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static DataTable Query(string condition, PagingArg pagingArg, params string[] propertyNames);
protected static DataTable Query(string condition, PagingArg pagingArg, bool sqlServer2000, params string[] propertyNames);
protected static DataTable QueryAll(params string[] propertyNames);
protected static DataTable QueryTop(int topCount, params string[] propertyNames);
protected static DataTable QueryTop(string condition, int topCount, params string[] propertyNames);
public ArrayList RetrieveAssociations();
public ArrayList RetrieveAssociations(Type elementType);
public ArrayList RetrieveAssociations(params Type[] elementTypes);
public void RetrieveById();
public void RetrieveByPK();
protected internal virtual void RetrieveBySql(string sql);
public void ShadowCopyTo(object targetEntity);
public void ShadowCopyTo(T targetEntity);
protected static double Sum(string columnName);
protected static double Sum(string columnName, string condition);
protected static List<double> SumGroup(string columnName, string groupBy);
protected static List<double> SumGroup(string columnName, string condition, string groupBy);
public static string ToColumnName(string propertyName);
public static T ToObject(DataRow adaptedRow);
public static List<T> ToObjects(DataTable adaptedTable);
public static List<T> ToObjects(DataRow[] adaptedRows);
public static string ToPropertyName(string columnName);
public static DataTable ToTable(IList<T> entities);
public static DataTable ToTable(params T[] entities);
public static DataTable ToTable(bool isAdapted, params T[] entities);
public static DataTable ToTable(bool isAdapted, IList<T> entities);
// Properties
protected internal static string CommandText { get; }
protected internal static GatewayConfig Config { get; }
internal T Entity { get; set; }
public object EntityId { get; }
public object PrimaryKey { get; }
protected static Order SortedOrder { get; set; }
}
public abstract class TableGateway<T> : ViewGateway<T> where T: TableGateway<T>, new()
{
// Methods
static TableGateway();
protected TableGateway();
public int AddNew();
public static int AddNew(IList<T> entities);
public static int AddNew(T entity);
public int AddNew(bool returnIdentity);
public static int AddNew(T entity, bool returnIdentity);
public static int AddNew(IList<T> entities, out Transaction transaction);
public static int AddNew(IList<T> entities, bool returnIdentity);
public static int AddNew(T entity, out Transaction transaction);
public static int AddNew(IList<T> entities, bool returnIdentity, out Transaction transaction);
public static int AddNew(T entity, bool returnIdentity, out Transaction transaction);
public IDbTransaction BeginTransaction();
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel);
public IDbTransaction BeginTransaction(double activeTime);
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel, double activeTime);
public bool Commit();
protected static int Delete(string condition);
protected static int Delete(string condition, out Transaction transaction);
public int DeleteById();
public static int DeleteById(T entity);
public static int DeleteById(IList<T> entities);
public static int DeleteById(IList<T> entities, out Transaction transaction);
public static int DeleteById(T entity, out Transaction transaction);
public int DeleteByPK();
public static int DeleteByPK(T entity);
public static int DeleteByPK(IList<T> entities);
public static int DeleteByPK(IList<T> entities, out Transaction transaction);
public static int DeleteByPK(T entity, out Transaction transaction);
protected void OnPropertyChanged(MethodBase propertyMethod);
protected void OnPropertyChanged(string propertyName);
protected internal override void RetrieveBySql(string sql);
public bool Rollback();
protected static int Update(T entity, string condition);
protected static int Update(T entity, string condition, out Transaction transaction);
public int UpdateById();
public static int UpdateById(IList<T> entities);
public static int UpdateById(T entity);
public static int UpdateById(T entity, out Transaction transaction);
public static int UpdateById(IList<T> entities, out Transaction transaction);
public int UpdateByPK();
public static int UpdateByPK(IList<T> entities);
public static int UpdateByPK(T entity);
public static int UpdateByPK(IList<T> entities, out Transaction transaction);
public static int UpdateByPK(T entity, out Transaction transaction);
// Properties
public bool Changed { get; }
public List<string> ChangedPropertyNames { get; }
}
public class StoredProcedure<T> : IStoredProcedure
{
public bool BeginTransaction();
public void CloseReader(IDataReader reader);
public bool Commit();
public DataSet ExecuteDataSet();
public DataTable ExecuteDataTable();
public DataTable ExecuteDataTable<Ttarget>();
public List<Ttarget> ExecuteEntity<Ttarget>();
public int ExecuteNonQuery();
public IDataReader ExecuteReader();
public object ExecuteScalar();
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
protected void InitializeInstance(T entity);
public bool Rollback();
}
public class AggregateEntity<T> where T: AggregateEntity<T>, new()
{
public static List<T> Execute();
protected static List<T> Execute(string condition);
public static DataTable ExecuteDataTable();
protected static DataTable ExecuteDataTable(string condition);
protected static void InitializeGateway(GatewayConfig config);
protected static void InitializeGateway(DatabaseType dbType, string connectionString);
// Properties
protected static Order SortedOrder { get; set; }
}
public static class EntityMapper<T>
{
// Methods
public static void AdaptToDatabase(DataTable adaptedTable);
public static void AdaptToEntity(DataTable rawTable);
public static void CopyToEntities(IList<T> entities, IList<DataRow> adaptedRows);
public static void CopyToEntities(IList<T> entities, DataTable adaptedTable);
public static void CopyToEntity(T entity, DataRow row);
public static List<T> CreateEntities(int count);
public static DataTable CreateTable();
public static DataTable CreateTable(bool isAdapted);
public static string ToColumnName(string propertyName);
public static List<T> ToEntities(IList<DataRow> adaptedRows);
public static List<T> ToEntities(DataTable table);
public static T ToEntity(DataRow adaptedRow);
public static string ToPropertyName(string columnName);
public static DataTable ToTable(IList<T> entities);
public static DataTable ToTable(params T[] entities);
public static DataTable ToTable(bool isAdapted, params T[] entities);
public static DataTable ToTable(bool isAdapted, IList<T> entities);
}
public static class EntityUtility
{
// Methods
public static List<T> Inherit<T>(IList entities);
public static T Inherit<T>(object entity);
public static T Inherit<Tbase, T>(Tbase baseEntity, TransformAction<Tbase, T> method);
public static List<T> Inherit<Tbase, T>(IList<Tbase> baseEntities, TransformAction<Tbase, T> method);
public static void ShadowCopy(IList targetEntities, IList sourceEntities);
public static void ShadowCopy(object targetEntity, object sourceEntity);
}
对象关系映射架构(DBFrameworkV4.5.1)及代码生成器
不用編寫SQL語句或存儲過程即可實現下列功能: 1、數據表、試圖與對象之間的轉換。 2、數據表、試圖的普通和分頁查詢。 3、數據表的完全新增或部分新增(單個對象、多個對象)。 4、數據表的完全更新或部分更新(單個對象、多個對象)。 5、數據表的刪除或條件刪除。 6、自動加載關系對象,實現一對一、一對多、多對一和多對多的關系映射。 7、支持單個對象和多個對象之間的事務。 8、支持查詢表達式的生成。 9、支持查詢結果排序。 10、延遲加載。 11、DataTable、DataRow與業務對象之間的映射轉換。 12、可指定數據庫鏈接,自動生成C#代碼及其相關的工程文件,生成完整的業務層項目文件。 13、可在VS中設計XSD文件,並根據XSD文件,自動生成C#代碼及其相關的工程文件,生成完整的業務層項目文件。 <br><br>提供<br>1、对象关系映射组件: Kenly.DBFramework.dll<br>2、代码生成器:Xsd2CS.exe<br>3、范例:数据库脚本、ASP.NET工程<br>4、使用手册。
ORM-對象關系映射架構(DBFrameworkDBFrameworkV4.5.1)及代碼生成器
不用編寫SQL語句或存儲過程即可實現下列功能:
1、數據表、試圖與對象之間的轉換。
2、數據表、試圖的普通和分頁查詢。
3、數據表的完全新增或部分新增(單個對象、多個對象)。
4、數據表的完全更新或部分更新(單個對象、多個對象)。
5、數據表的刪除或條件刪除。
6、自動加載關系對象,實現一對一、一對多、多對一和多對多的關系映射。
7、支持單個對象和多個對象之間的事務。
8、支持查詢表達式的生成。
9、支持查詢結果排序。
10、延遲加載。
11、DataTable、DataRow與業務對象之間的映射轉換。
12、可指定數據庫鏈接,自動生成C#代碼及其相關的工程文件,生成完整的業務層項目文件。
13、可在VS中設計XSD文件,並根據XSD文件,自動生成C#代碼及其相關的工程文件,生成完整的業務層項目文件。
[Serializable()]
[Table(TableName = "usyUser")]
public class BusinessUser : SqlTableGateway<BusinessUser>, ICloneable
{
public BusinessUser()
{
string connectionString = SystemConfig.ConnectionString;
base.InitializeGateway(connectionString, this);
}
略.............
#region Properties
[Column(ColumnName = "UserId", IsIdentity = true, IsPrimaryKey = true)]
public int UserId
{
get { return _userId; }
set { _userId = value; }
}
[Column(ColumnName = "EmployeeNumber")]
public string EmployeeNumber
{
get { return _employeeNumber; }
set { _employeeNumber = value; }
}
[Column(ColumnName = "UserName")]
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
Role[] _roles = new Role[0];
[Relation(RelationType = RelationType.ManyToMany, InterrelationType = typeof(UserRole), ResultOrder = "RoleName ASC")]
public Role[] Roles
{
get { return _roles; }
set { _roles = value; }
}
public DataTable RoleTable
{
get
{
Role role = new Role();
return role.ToTable(_roles, false);
}
}
#endregion //Properties
}
Role role = new Role();
gvRole.DataSource = role.QueryAll();
gvRole.DataBind();
Role role = new Role();
int roleId=1;
role.RoleId = roleId;
role.IsActive = false;
role.PartialUpdateById("IsActive") ;
Role role = new Role();
int roleId=1;
role.RoleId = roleId;
role.RetrieveById();
role.IsActive = false;
role.UpdateById() ;
BusinessUser user = new BusinessUser();
user.UserId = 2;
user.RetrieveRelationObject(typeof(Role));
需要使用說明及代碼生成器,請聯系 lknoodle@sohu.com
考慮到外國同事的使用,目前只提供英文版。
ORM -DBFrameworkV4.5.1
不用編寫SQL語句或存儲過程即可實現下列功能: <br>1、數據表、試圖與對象之間的轉換。 <br>2、數據表、試圖的普通和分頁查詢。 <br>3、數據表的完全新增或部分新增(單個對象、多個對象)。 <br>4、數據表的完全更新或部分更新(單個對象、多個對象)。 <br>5、數據表的刪除或條件刪除。 <br>6、自動加載關系對象,實現一對一、一對多、多對一和多對多的關系映射。 <br>7、支持單個對象和多個對象之間的事務。 <br>8、支持查詢表達式的生成。 <br>9、支持查詢結果排序。 <br>10、延遲加載。 <br>11、DataTable、DataRow與業務對象之間的映射轉換。 <br>12、可指定數據庫鏈接,自動生成C#代碼及其相關的工程文件,生成完整的業務層項目文件。 <br>13、可在VS中設計XSD文件,並根據XSD文件,自動生成C#代碼及其相關的工程文件,生成完整的業務層項目文件。