2012-04-03 5 views
-2

に、私は次のようしたエラーブールのIQueryable

Error 1 Cannot implicitly convert type 'LightSwitchApplication.PatientsTelephoneFollowupDetail' to 'bool' 
Error 2 Cannot convert lambda expression to delegate type 'System.Func<LightSwitchApplication.PatientsTelephoneFollowupDetail,int,bool>' because some of the return types in the block are not implicitly convertible to the delegate return type 

コードが

partial void StatusCallBackRequired_PreprocessQuery(ref IQueryable<PatientsTelephoneFollowupDetail> query) 
{ 

    query = query.Where(p=> p.PatientsMasterItem.PatientsTelephoneFollowupDetail.LastOrDefault(c => c.Status == "7")); 

} 

は私が7

+4

あなたはあなたが何を望んでいるかをもう少し明確にする必要があります。私はOPが明確にする努力をしなかったように見える質問に答えるのが好きではない。 – JayC

答えて

3

.LastOrDefault意志まだリターンとして最後の電話のステータスを持つ患者のレコードを返したいですa PatientsTelephoneFollowupDetail。エラーが示すように、真偽値ではありません。あなたは、アイテムの存在を確認したい場合は、.Anyを使用します。

query = query.Where(p => p.PatientsMasterItem.PatientsTelephoneFollowupDetail.Any(c => c.Status == "7")); 
0

デリゲートWhere内のブール値を返す必要があります。

p => p.PatientsMasterItem.PatientsTelephoneFollowupDetail.LastOrDefault(c => c.Status == "7") 

は間違いなく1になります。

正確に何をしますか?

+0

最後の電話ステータスが7の患者レコードを返信したいと思っています – user1213055

+0

質問に追加しても大丈夫でした*(すごい、それでもやることができます) – JayC

+0

期待される結果。更新しました。 – user1213055

0

.Whereではなく、.Selectを使用する必要があります。