none
How to return a gereric list for IQuerable RRS feed

  • Frage

  • Hi,

    I am brand new to EF. So as a starting point I used a Lab from VS2010 TrainingsKit. It is the first lab called WinForms.

    I decided to have a WCF service, because I wanted to have a n-tier layer application, to which I can attacht a WPF Application in furture- So far so good.

    In my EDM I basically have three tables Roles ==> UserRoles ==> User. In a datagrid I want to display all uses and their roles, not in a hierarchical  view, but a flat view. It want to end up in something like this: ID_User, FirstNmae, LastName, LoginName, ID_Role and Role(human readable explanation).

     

    I get hold of Role and User-Entities, and I can display their contents. But as explained above this is not my target.

    Whithin my repository I defined folowing method:

    public  IQueryable GetUserRechte()

    {

    using (DataContext)

    {

    var  getUserRechte = from u in DataContext.MCUsers join ur in DataContext.UserRechte

                                   on u.ID_MCUser equals ur.ID_MCUser

                                   select new { u.ID_MCUser, u.FirstName , u.Name , u.LoginName, u.Remark, ur.ID_Rolle 

    };   

    return getUserRechte;

    }

    Using Linqpad this linq-query returns just what I need and want.

    When I try to access the result set, I either get annoying error messages or my business / data- layer is not invoced. As my result is of type IQuerable I suggest to transform it into a gereric list object. How can I cast my resutlset into a generic list for consumption?

    I'd appreciate your help.

     

     

     


    A_SqlDeveloper
    Montag, 2. Mai 2011 17:41

Antworten

Alle Antworten