views:

327

answers:

0

Please read my question carefully and reply me.

I have two tables as table1 and table2.

In table1 i have columns as AddressID(Primary Key),Address1,Address2,City

In table2 i have columns as ContactID(Primary Key),AddressID(Foriegn Key),Last Name,First Name.

By using join operation i can retrive data from both the tables.

I created a Model in my MVC Application.I can see both the tables in enitity editor.

In the ViewData folder of my solution explorer i created two class as ContactViewData.cs and SLXRepository.cs

In the ContactViewData.cs i have following code

public IEnumerable<CONTACT> contacts
{
    get;
    set;
}

In the SLXRepository.cs i have following code

public  IEnumerable<CONTACT> GetContacts()
{
    var contact =
    (
        from c in context.CONTACT
            join a in context.ADDRESS on c.ADDRESSID equals a.ADDRESSID
            select new
            {
                a.ADDRESS1, 
                a.ADDRESS2,
                a.CITY,
                c.FIRSTNAME,
                c.LASTNAME
            }
    );

    return contact;
}

I am getting the error in return type Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?)