var list = db.eis_website_news.ToList(); foreach (var molel in list) { try { SitesDetails sitedetail = new SitesDetails(); if (molel.typeid == null) { sitedetail.SitesId = 10000068; } else { string TypeTitle = db.eis_website_list.Find(molel.typeid).title; if (TypeTitle == null) { sitedetail.SitesId = 10000068; } else { DateTime dt = Convert.ToDateTime("2016-10-16 18:00:00"); Sites site = db.Sites.Where(a => a.CreateDate > dt).FirstOrDefault(a => a.Name == TypeTitle); if (site == null) { sitedetail.SitesId = 10000068; } else { sitedetail.SitesId = site.Id; } } } sitedetail.SiteDetailId = CommonHelper.GetGuid; sitedetail.CompanyId = "069c8bfa-7023-4a1a-86b8-1bc47c4a0924"; sitedetail.Title = molel.title; sitedetail.Content = molel.content; sitedetail.PictureUrl = molel.c_image; sitedetail.CreateDate = molel.addtime; sitedetail.CreateUserName = molel.auth; sitedetail.AuditUserId = "11a44238-21da-4cfd-b7c2-b53872c4df6f"; db.Entry(sitedetail).State = EntityState.Added; db.SaveChanges(); } catch { continue; } }
时间: 2024-10-18 21:18:08