Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery, DbRawSqlQuery) is not supported' Hatası

Tuğçe
26 Ağustos 2016 Cuma
3

Merhaba arkadaşlar,

Uygulama yaparken karşılaştığım bir hatanın çözümünü sizlerle paylaşmak istedim.Aldığım hata şu şekildeydi.

Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery, DbRawSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data. For WPF bind to DbSet.Local. For WinForms bind to DbSet.Local.ToBindingList(). For ASP.NET WebForms you can bind to the result of calling ToList() on the query or use Model Binding

Bu hata genellikle bir combobox,dropdownlist,listbox veya repeater gibi elemanlara datasource verdiğimiz satırda ToList() ifadesinin yazılmamasından kaynaklanan bir hatadır.

Aşağıdaki kod örneğinde görüldüğü gibi hatanızı db.products ifadesinin sonuna ToList() ekleyerek çözebilirsiniz.

            cmbUrunler.DataSource = db.Products.ToList();
            cmbUrunler.DisplayMember = "ProductName";
            cmbUrunler.ValueMember = "ProductID";

İyi çalışmalar



yorumlar
64x64

10 Eylül 2016 Cumartesi
Hi Are you having trouble acquiring new clients because you are waiting 30, 60 or even 90 days for payments. Imagine having the ability to accept every job available to you without having to worry about money to finance the job? At Globelend Capital, we are able to get you the funds you need when you need it. We approve 95% of our clients and offer the best rates and longest terms in the unsecured market. Find out how much you qualify for by visiting our website and receiving your no risk and no obligation quote. Get your cash now and see your lending options in just 1 hour. No Cost Or obligation to you so call us today or apply online! Apply Online Here: http://www.globelend.net/application Having trouble acquiring inventory for your Would an influx of capital increase your business and get you a better rate on your products. Imagine having the ability to purchase large quantities of inventory to reduce your cost and increase your profits. At Globelend Capital, we are able to get you the funds you need when you need it. We approve 95% of our clients and offer the best rates and longest terms in the unsecured market. Find out how much you qualify for by visiting our website and receiving your no risk and no obligation quote. Filled online in your contact form. Thank you Jayzon Estrella Business Financial Consultant Direct: 305-900-6538 Fax: 786-664-3340
64x64

Veli

4 Temmuz 2018 Çarşamba

veryy veryy thanks friend. Very nice

64x64

Kaan

15 Eylül 2022 Perşembe

Gerçekten çok yardımcı oldu teşekkürler.

Yorum yaz