public static void SyncCategory(List <CategoryData> list) { try { //string json = Newtonsoft.Json.JsonConvert.SerializeObject(list); /* * Unable to complete operation. The supplied SqlConnection does not specify an initial catalog or AttachDBFileName. */ DBReporistory <CategoryData> md = new DBReporistory <CategoryData>(new ConfigurationItems().SqliteDbConnString); List <CategoryData> dstas = md.DoQuery <CategoryData>().ToList(); //一次操作数据量过大需要分批次 List <CategoryData> group = new List <CategoryData>(); for (int i = 0; i < list.Count; i++) { group.Add(list[i]); if (i % 2 == 0) { md.AddList(group.ToArray()); group.Clear(); } } } catch (Exception ex) { } }
public void SaveQQ(List <FindQQDataTable> data) { try { //由于sqlite不支持guid数据存储:直接存储会变成乱码 DBReporistory <TecentQQData> main = new DBReporistory <TecentQQData>(ConnString); DateTime now = DateTime.Now; List <TecentQQData> tcs = new List <TecentQQData>(); foreach (FindQQDataTable item in data) { NoIDQQData noKey = item.ConvertMapModel <FindQQDataTable, NoIDQQData>(); TecentQQData tc = noKey.ConvertMapModel <NoIDQQData, TecentQQData>(); tc.ID = GenerateId(); tc.CreateTime = now; if (string.IsNullOrEmpty(tc.Url))//没有采集到该账户的头像数据 { tc.ImgType = -1; } tc.DayInt = int.Parse(now.ToString("yyyyMMdd")); tcs.Add(tc); } main.AddList(tcs.ToArray()); } catch (Exception ex) { /* 原因:sqlite不支持实体列数据类型为Guid的情形 * One or more validation errors were detected during model generation: * * Infrastructure.EFSQLite.TecentQQData: : EntityType 'TecentQQData' has no key defined. Define the key for this EntityType. * Entity: EntityType: EntitySet 'Entity' is based on type 'TecentQQData' that has no keys defined. * */ } }
public static void SyncCategory(List <CategoryData> list) { try { DBReporistory <CategoryData> md = new DBReporistory <CategoryData>(new ConfigurationItems().SqliteDbConnString); List <CategoryData> dstas = md.DoQuery <CategoryData>().ToList(); //一次操作数据量过大需要分批次 List <CategoryData> group = new List <CategoryData>(); for (int i = 0; i < list.Count; i++) { group.Add(list[i]); if (i % 2 == 0) { md.AddList(group.ToArray()); group.Clear(); } } } catch (Exception ex) { } }