c# - Type of one of the expressions in the join clause is incorrect -


i´m learning linq , trying use cross join error: type of 1 of expressions in join clause incorrect

isn´t possible use getcategories() in cross join? request in main functions outside of it.

var q = c in getcategories()         join p in getproducts() on c equals p.categoryid         c.name = "beverages"         select new { id = c, p.name }; 

method signatures:

public static ienumerable<category> getcategories() list<category> categories = new list<category>( ); categories.add( new category { id = 1, name = "beverages" } );  public static ienumerable<product> getproducts() list<product> products = new list<product>( ); products.add( new product { name = "milk",           price = 90,  categoryid = 4, id = 1 } ); 

you need specify field in category class join on.. id:

from c in getcategories() join p in getproducts() on c.id equals p.categoryid c.name == "beverages" select new { id = c.id, p.name }; 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -