none
Linq Query Error condition - combobox.ValueMember RRS feed

  • Question


  • ComboboxCourse.DataSource = from p in db.Courses
    where p.IdEducationGroup = Combobox.EducationGroup.ValueMember => error
    select new { p.IdCourse, p.NameCourse }

    and

    int id=ideg;
    var rb=from p in db.ClassRoom
    where p.IdEducationGroup = id => error
    select new { p.IdClassRoom, p.NameClassRoom }
    • Moved by Anna Cc Friday, July 18, 2014 6:42 AM
    Wednesday, July 16, 2014 10:38 PM

Answers

  • Hello,

    Let me guess that your error message is like “Cannot implicitly convert type 'int' to 'bool'”. In the where clause, we should use “==” rather than single “=”. And 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(). So you might write code as:

    comboBox1.DataSource = (from order in db.Orders
    
                                        where order.OrderID == 1
    
                                        select new { OrderID = order.OrderID }).ToList();
    

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 18, 2014 7:11 AM
    Moderator

All replies

  • Hi,

    I'm moving this case to LINQ to SQL forum for better response.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 18, 2014 6:41 AM
  • Hello,

    Let me guess that your error message is like “Cannot implicitly convert type 'int' to 'bool'”. In the where clause, we should use “==” rather than single “=”. And 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(). So you might write code as:

    comboBox1.DataSource = (from order in db.Orders
    
                                        where order.OrderID == 1
    
                                        select new { OrderID = order.OrderID }).ToList();
    

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 18, 2014 7:11 AM
    Moderator