日期:2014-05-20 浏览次数:21086 次
DataClasses1DataContext ct = new DataClasses1DataContext();
for (int i = 0; i < 10000; i++)
{
Common_Gen m = new Common_Gen();
m.GenId = 1;
m.GenType = "Type";
m.Memo = "Memo";
m.UpdateDate = DateTime.Now;
ct.Common_Gen.InsertOnSubmit(m);
}
ct.SubmitChanges();
/// <summary>
/// 新增数据
/// </summary>
/// <typeparam name="TEntity">实体</typeparam>
/// <param name="table">Table</param>
/// <returns>n</returns>
public static int Add<TEntity>(this Table<TEntity> table, TEntity entity) where TEntity : class
{
DbCommand cmd = table.Context.Connection.CreateCommand();
Type entityType = typeof(TEntity);
var metaTable = table.Context.Mapping.GetTable(entityType);
ReadOnlyCollection<MetaDataMember> dataMembers = metaTable.RowType.DataMembers;
List<object> values = new List<object>();
//自动增长列
string IsDbGeneratedColumnName = null;
StringBuilder sbColumnNames = new StringBuilder();
StringBuilder sbValues = new StringBuilder();
foreach (MetaDataMember mm in dataMembers)
{
if (!mm.IsDbGenerated && mm.DbType != null)