【发布时间】:2018-10-06 15:00:13
【问题描述】:
我有这个方法
public List<Trgovina> getAllStores()
{
using (IDbConnection connection = new MySqlConnection(Helper.CnnVal("dbConn")))
{
return connection.Query<Trgovina>("TrgovineViewAll", null,
commandType: CommandType.StoredProcedure
)
.ToList();
}
}
它从数据库中获取所有商店信息。启动时调用的方法
public MainWindow()
{
InitializeComponent();
List<Trgovina> stores = new List<Trgovina>();
stores = da.getAllStores();
comboxStoreNames.ItemsSource = stores;
}
stores 充满了数据。虽然数据不是我需要的格式。它只显示{Project_Budget.Engine.Trgovina}。我需要的信息就在里面。如何以字符串格式从那里获取该数据,以便在组合框中显示它?
【问题讨论】:
-
你为什么不使用数据源和 DisplayMember 和 ValueMember ? stackoverflow.com/questions/12494634/…