/// <summary> /// 初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnInit_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtPath.Text)) { MessageBox.Show("请选择Domain路径"); return; } rtxtDAL.Document.Blocks.Clear(); entityClassInfos = new List <EntityClassInfo>(); try { foreach (var table in tableModels) { DataTable dt = new DataTable(); DataTable dtComent = new DataTable(); if (table.Checked) { var factory = new FactoryDb(dbTypeComboBox.SelectedValue.ToString()); dt = factory.GetTableInfo(connenction, table.Name); dtComent = factory.GetTableComment(connenction, table.Name); var str = Newtonsoft.Json.JsonConvert.SerializeObject(dtComent); List <Model.EntityInfo> entityInfos = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Model.EntityInfo> >(str); entityInfo = new EntityClassInfo(dt, entityInfos); entityClassInfos.Add(entityInfo); } } if (entityClassInfos.Count > 0) { CodeGenerator.IsEnabled = true; CreateCode.CreateInitClass(entityClassInfos[0]); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }