在linq中对wp7中的三个表进行联接查询 [英] join queries in linq for three table in wp7
本文介绍了在linq中对wp7中的三个表进行联接查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在
下创建了一个Web服务.
i had created one web service as under
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();
}
但这会在return语句中给我错误....
我的退货类型应该是什么..
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)
推荐答案
问题实际上是Linq问题,而不是WP7问题.当您执行select new {...}语句时,该查询将成为匿名类型.这与List< string>方法的返回类型.
您也许可以尝试像这样更改查询...
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...
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.
这篇关于在linq中对wp7中的三个表进行联接查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文