因自己学习测试需要,需要两个有大量不重复行的表,表中行数越多越好.手动编写SQL语句,通过循环,批量向表中插入数据,考虑到避免一致问题,设置奇偶行不同.个人水平有限,如有错误,还望指正. 语句如下: 1 --批量向表中插入大量数据语句(奇偶不同) 2 3 --判断测试表是否存在,存在则先删除再创建 4 if exists(select 1 from sysobjects where xtype='u' and name='table_test' ) 5 drop table table_test
using ServiceStack; using ServiceStack.DataAnnotations; using ServiceStack.OrmLite; using ServiceStack.Text; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2.tes
Expression构建DataTable to Entity 映射委托 1 namespace Echofool.Utility.Common { 2 using System; 3 using System.Collections.Generic; 4 using System.Data; 5 using System.Linq.Expressions; 6 using System.Reflection; 7 using System.Reflection.Emit; 8 9 publ
使用过ServiceStack.Ormlite的人都应该知道,其作为一个轻量级的ORM,使用的便捷度非常高,用起来就一个字:爽!而支撑其便捷度的,是库内大量地使用了扩展方法及静态变量. 首先先从源头入手分析(以下以Sqlite为例): OrmLiteConfig.DialectProvider = SqliteOrmLiteDialectProvider.Instance; using (IDbConnection db = "~/db.sqlite".MapAbsolutePath(
复杂点的使用1 先看看这2个类 class Customer { public int Id { get; set; } ... } class CustomerAddress { public int Id { get; set; } public int CustomerId { get; set; } // Reference based on Property name convention } --- 也支持 别名 [Alias("LegacyCustomer")] clas
对表中数据分组,有时只需要某列的聚合值:有时却需要返回整行数据,常用的方法有:子查询.ROW_NUMBER.APPLY,总体感觉还是ROW_NUMBER比较直观.测试数据: if OBJECT_ID('testGroup') is not null drop table testGroup GO create table testGroup ( ID int identity primary key, UserID int, OrderID int ) GO insert testGroup ,