Avatar of Plexo
Plexo
 asked on

How do I use a IQueryable return

I am using Sillverlight 4 Business Application
The Domain Service returns a EntityQuery

DomainService
public IQueryable<NFe_C_emit> GetNFe_C_emit()
        {
            return this.ObjectContext.NFe_C_emit;
        }

My xaml
private void btnPesquisar_Click(object sender, RoutedEventArgs e)
        {

            dataGrid1.ItemsSource = db.GetNFe_C_emitQuery();
        }

ERROR
Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.EntityQuery<NFe.Web.NFe_C_emit>' to 'System.Collections.IEnumerable'

Questions:
1) How can I convert this to a IEnumerable<> for use in a DataGrid
2) How can I access row by row of this return.

Thanks


.NET Programming

Avatar of undefined
Last Comment
kris_per

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
kris_per

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Plexo

ASKER
The LoadOperation worked well for the DataGrid.
However for the List does not work.
The operation [for each] performed before bringing the record.
As I await the end of the operation to run [for each]?

<OK>
        private void btnPesquisar_Click(object sender, RoutedEventArgs e)
        {
            EntityQuery<NFe_C_emit> query =
                from c in _customerContext.GetNFe_C_emitQuery()
                select c;
            LoadOperation<NFe_C_emit> loadOp = this._customerContext.Load(query);
            dataGrid1.ItemsSource = loadOp.Entities;
        }

<NOT WORK>  
      private void btnSelecionar_Click(object sender, RoutedEventArgs e)
        {
            EntityQuery<NFe_C_emit> query =
                from c in _customerContext.GetNFe_C_emitQuery()
                select c;
            LoadOperation<NFe_C_emit> loadOp = this._customerContext.Load(query);
            List<NFe_C_emit> list = loadOp.Entities.ToList();
            foreach (NFe_C_emit item in list)
            {
                textBox1.Text = item.xNome;
            }
        }
Gururaj Badam

dataGrid1.ItemsSource = db.GetNFe_C_emitQuery().AsEnumerable<NFe_C_emit>();
Gururaj Badam

for that to work you should have added System.Data.DataSetExtensions reference to your project
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
kris_per

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.