【发布时间】:2013-01-15 21:11:49
【问题描述】:
我正在尝试获取存储在本地数据库中的数据。我正在使用这样的东西:
// Connect to the database and instantiate data context.
tablesDB = new TablesDataContext(TablesDataContext.DBConnectionString);
// Define the query to gather all of the items.
var CategoriesTablesInDB = from CategoryItem todo in tablesDB.CategoriesTable
select todo;
// Execute the query and place the results into a collection.
CategoriesTable = new ObservableCollection<CategoryItem>(CategoriesTablesInDB);
但是我的CategoriesTable在这样做之后有count = 0,而CategoriesTablesInDB里面有它的sql查询。我是 Windows Phone 新手,如果这样做是正确的方法,我不会。是我的查询有问题,还是我做得不对?
【问题讨论】:
-
@spajce 对不起,但这不是我要问的
-
是的。我的意思是你试图在
ObservableCollection中添加项目:) -
@spajce 好吧...我并没有尝试完全添加项目..我没有列表或任何东西。我正在尝试执行返回我项目的查询。所以我不认为遍历所有元素是可能的。
-
我设法解决了这个问题。一切都很好,我只是有空数据库。
标签: c# windows-phone-8 local-database