C#批量向数据库增加数据: ----------------------------- using (var dbPlatform = DbContext.PlatformWorkCreate()) { var CId = dbPlatform.Query<LQ_WaWaShowCategory>().Where(t => t.CategoryNameEn == "dianzijiaocai").Select(t => t.Id).FirstOrDefault(); for (int i = 0; i < model.SelectedIds.Count; i++) { LQ_PublicResourceOutline dmodel = null; dmodel=new LQ_PublicResourceOutline(); dmodel.LQ_OutlineId = model.SelectedIds[i]; dmodel.CategoryId = CId; dmodel.PublishStatus = 0; dmodel.Summary = ""; dbPlatform.Add(dmodel); } dbPlatform.SaveChanges(); }
时间: 2024-10-07 06:57:40