join子句中某个表达式的类型不正确。类型推断在加入调用中失败 [英] the type of one of the expressions in the join clause is incorrect. type inference failed in the call to join

查看:265
本文介绍了join子句中某个表达式的类型不正确。类型推断在加入调用中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Wpf,后端编码是linq to sql。

我尝试加入两个查询,但发生的异常是join子句中某个表达式的类型不正确。在加入调用中类型推断失败

我的代码ID: -

I am using Wpf and backend coding is linq to sql.
I am try to join two query but an exception occur that is "the type of one of the expressions in the join clause is incorrect. type inference failed in the call to join "
my code id:-

var accountDetail = from account in accountSD.Accounts
                                         join
                                         studentMaster in accountSD.StudenMasterTables on account.Alias equals studentMaster.stdACID 
                                         select new
                                            {
                                                account.Aid,
                                                account.Alias,
                                                account.AccountId,studentMaster.stdCARDID,
                                                studentMaster.stdName,
                                                studentMaster.stdFather
                                            } ;



如何解决这个问题?


how to solve this problem ??

推荐答案

//The  Type name on each side of the equals operator has to be the same
//So try doing this 
var accountDetail = from account in accountSD.Accounts
                    join
                    studentMaster in accountSD.StudenMasterTables  
                    on 
                    new {account.Alias} equals new{Alias=studentMaster.stdACID}


这篇关于join子句中某个表达式的类型不正确。类型推断在加入调用中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆