Henry Henry - 1 year ago 105
C# Question

C# Winform (Entity Framework) - Iterate thru DBLocal

I am working with a project modeled on this link: Databinding with WinForms

On the form load on the link, the tutorial set the binding to:

this.categoryBindingSource.DataSource =

my question is, is it possible to iterate rows and columns on DBlocal?
? If Yes, how?

Thanks in Advance.

Answer Source

DbSet<T>.Local property is ObservableCollection<T> and you can simply use a for/foreach loop. You can use either of these options:

foreach (Category item in context.Category.Local)
for (int i = 0; i < context.Category.Local.Count; i++)
    var item = context.Category.Local[i];
       .ForEach(item =>

Don't forget to first load data to Local.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download