Cannot initialize type '' with a collection initializer because it does not implement 'System.Collections.IEnumerable' Cannot initialize type '' with a collection initializer because it does not implement 'System.Collections.IEnumerable' asp.net asp.net

Cannot initialize type '' with a collection initializer because it does not implement 'System.Collections.IEnumerable'


You are using here the collection initializer in C# :

new myClass{a,b,c} 

where myClass is a collection, and a,b,c will be inserted into this collection.

But, the notation you need to use is the object initializer:

new myClass{   myProperty1 = a,   myProperty2 = b,   myProperty3 = c}

where the member of a myClass will be initialized. Or maybe you need to use classic constructor and then change your bracket with parenthesis:

new myClass(a,b,c)


Should be:

var query = from r in ent.Rentals           join a in ent.Agents on r.ListingAgentID equals a.AgentID           select new Feeds           {                    Agents = a,                    Rentals = r           }