public void Add() { int id = 0; for (int i = 1; i <= 400000; i++) { for (int j = 1; j <= 5; j++) { id++; t4_json jsonmodel = new t4_json(); List <T2_ModifyLogModel> lst = new List <T2_ModifyLogModel>(); for (int k = 1; k <= 5; k++) { T2_ModifyLogModel mmodel = new T2_ModifyLogModel(); mmodel.Column205 = "Column205" + "-" + k.ToString() + j.ToString(); mmodel.Column206 = "Column206" + "-" + k.ToString() + j.ToString(); mmodel.Column207 = "Column207" + "-" + k.ToString() + j.ToString(); lst.Add(mmodel); } jsonmodel.id = id; jsonmodel.houseid = i; jsonmodel.codeid = j; jsonmodel.jsonstr = JsonHelper.Instance.Serialize(lst);; jsonmodel.Insert(); } } }
public void Add() { int code = 0; Parallel.For(1, 400001, i => { Parallel.For(1, 6, j => { t4_json jsonmodel = new t4_json(); List <T2_ModifyLogModel> lst = new List <T2_ModifyLogModel>(); Parallel.For(1, 6, k => { T2_ModifyLogModel mmodel = new T2_ModifyLogModel(); mmodel.Column205 = "Column205" + "-" + k.ToString() + j.ToString(); mmodel.Column206 = "Column206" + "-" + k.ToString() + j.ToString(); mmodel.Column207 = "Column207" + "-" + k.ToString() + j.ToString(); lst.Add(mmodel); }); int id; lock (locker) { id = ++code; }; jsonmodel.id = id; jsonmodel.houseid = i; jsonmodel.codeid = j; jsonmodel.jsonstr = JsonHelper.Instance.Serialize(lst);; jsonmodel.Insert(); }); }); //for (int i = 1; i <= 400000; i++) //{ // for (int j = 1; j <= 5; j++) // { // t4_json jsonmodel = new t4_json(); // List<T2_ModifyLogModel> lst = new List<T2_ModifyLogModel>(); // for (int k = 1; i <= 5; i++) // { // T2_ModifyLogModel mmodel = new T2_ModifyLogModel(); // mmodel.Column205 = "Column205" + "-" + k.ToString() + j.ToString(); // mmodel.Column206 = "Column206" + "-" + k.ToString() + j.ToString(); // mmodel.Column207 = "Column207" + "-" + k.ToString() + j.ToString(); // lst.Add(mmodel); // } // jsonmodel.id = ++code; // jsonmodel.houseid = i; // jsonmodel.codeid = j; // jsonmodel.jsonstr = JsonHelper.Instance.Serialize(lst); ; // jsonmodel.Insert(); // } //} }