Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i had created one web service as under

SQL
public List<String> ge()
   {
      var r = from c in db.Favourite_tbls
                join o in db.Menu_tbls on c.fk_menu_id equals o.pk_menu_id
               select new
               {
                   o.menu_name
               };
      return r.ToList();

   }


but it will give me error in return statement....
what should my return type..

Error:

cannot implicitly converts type system.collection.generic.list(annoymus type#1) to 
system.collection.generic.list(string)
Posted
Updated 25-Dec-11 22:27pm
v3

1 solution

The issue is really a Linq issue here and not a WP7 one. The query makes an anonymous type when you do the select new { ... } statement. This is not the same as the List<string> return type for the method.

You might be able to try changing the query like this...

SQL
public List<String> ge()
   {
      var r = from c in db.Favourite_tbls
                join o in db.Menu_tbls on c.fk_menu_id equals o.pk_menu_id
               select new String(o.menu_name);
      return r.ToList();

   }

You could also make a class that just had a string in it and use that as well. If you want a sample of that let me know.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900