//创建实体类调用add 实体类内部构造方法传this即可获取
new DataBaseInfo{
Id = Guid.NewGuid(),
Host = textBoxX2.Text,
Name = textBoxX1.Text,
ValidatorType= validator,
DbName = textBoxX6.Text,
Port = textBoxX3.Text,
DataType = FreeSql.DataType.SqlServer,
UserId = textBoxX4.Text,
Pwd = textBoxX5.Text
}.Add();
public class DataBaseInfo
{
string path = Path.Combine(Environment.CurrentDirectory, "database.bin");
List<DataBaseInfo> dataBases = new List<DataBaseInfo>();
public DataBaseInfo()
{
dataBases = Load();
}
public string Name { get; set; }
public List<DataBaseInfo> GetDataBaseInfos() => dataBases;
public Guid Id { get; set; }
public string UserId { get; set; }
public string Pwd { get; set; }
public string Host { get; set; }
public string DbName { get; set; }
public void Add()
{
dataBases.Add(this);
this.Save();
}
}