我沒有太多編程經驗。我正在(學習)一個項目。我正在使用EF(SQLite)C#4.0和WPF 4。我遇到了LINQ問題。來自EF麻煩的C#,Linq數據
這裏是有問題的代碼(我希望這是不夠的,讓我知道,如果需要更多)
private void cboSelectCompany_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
using (ShippingEntities context = new ShippingEntities())
{
var companies = from company in context.Deliveries
where company.State == cboSelectCompany.SelectedItem.ToString()
select company;
txtDeliveryName.Text = companies.Name;
txtDeliveryState.Text = companies.State;
}
最後兩行不工作。我誤解了LINQ返回的內容嗎?我剛剛得到這個錯誤
Error 5 'System.Linq.IQueryable<SqliteDemo.Delivery>' does not contain a definition for 'State' and no extension method 'State' accepting a first argument of type 'System.Linq.IQueryable<SqliteDemo.Delivery>' could be found (are you missing a using directive or an assembly reference?) c:\users\dan\documents\visual studio 2010\Projects\SqliteDemo\SqliteDemo\DeliveryCompanies.xaml.cs 49 51 SqliteDemo
如果任何人都可以給我一些指點還是一個很好的參考我將不勝感激
謝謝,這解決了它! – 2010-10-29 07:21:42