Entity Framework - ラムダ式はデリゲート型ではないため、「文字列」型に変換できません 質問する

Entity Framework - ラムダ式はデリゲート型ではないため、「文字列」型に変換できません 質問する

私は C# ベースのコードで Entity Framework を使用しています。予期しない奇妙な現象に遭遇したので、アドバイスを求めています。

ケース 1、2、3、4... プロジェクト:
RivWorks.dll
RivWorks.Service.dll
RivWorks.Alpha.dll

サンプル(すべて動作します):
RivWorks.Alpha.dll:

public static bool EndNegotitation(long ProductID)
{
    var product = (from a in _dbFeed.AutoWithImage 
                   where a.AutoID == ProductID select a).FirstOrDefault();
...
}

RivWorks.Service.dll

public static RivWorks.Model.NegotiationAutos.AutoWithImage 
    GetProductById(long productId)
{
    var myProduct = from a in _dbFeed.AutoWithImage 
                    where a.AutoID == productId select a;

    return myProduct.FirstOrDefault();
}
public static List<RivWorks.Model.NegotiationAutos.AutoWithImage> 
    GetProductByCompany(Guid companyId)
{
    var myProduct = from a in _dbFeed.AutoWithImage 
                    where a.CompanyID == companyId select a;

    return myProduct.ToList();
}

ケース「奇妙さ」:
RivWorks.Web.Service.dll (WCF プロジェクト)
他のプロジェクトと同じ参照が含まれています。

public NegotiateSetup GetSetup(string method, string jsonInput)
{
    ...
    long.TryParse(ProductID, out result);
    var product = (from a in _dbFeed.AutoWithImage 
                   where a.AutoID == result select a).FirstOrDefault();
    ...
}

次のコンパイル時エラーが発生します (エディターで「where」という単語が強調表示されます)。
ラムダ式はデリゲート型ではないため、「文字列」型に変換できません

この原因は何だと思いますか?

ベストアンサー1

結果に興味のある人のために:
コードの先頭に単純な Using ステートメントがありませんでした。

using System.Linq;

これですぐに直りました。

おすすめ記事