using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using SqlSugar; using HXX.Scanner.Database; namespace test_db { public partial class Form1 : Form { public Form1() { InitializeComponent(); } SqlSugarClient db; private void Form1_Load(object sender, EventArgs e) { try { db = SqlSugarHelper.GetClient(); } catch (Exception ee) { MessageBox.Show(ee.Message); } } private void button1_Click(object sender, EventArgs e) { try { create_entity("tb_file_info"); } catch (Exception ee) { MessageBox.Show(ee.Message); } } private string create_entity(string entityName) { try { if (entityName == null) { return "参数不能为空!"; } else { string filePath = Application.StartupPath; db.DbFirst.IsCreateAttribute().IsCreateDefaultValue().Where(entityName).CreateClassFile(filePath, "HXX.Scanner.Database"); return "操作成功!"; } } catch (Exception ee) { return "请求失败!"; } } private void button2_Click(object sender, EventArgs e) { try { var list = db.Queryable().ToList(); } catch (Exception ee) { MessageBox.Show(ee.Message); } } } }