AccountNumberが存在しないトランザクションデータを入力しようとしています。それを取得するには、Accountテーブルにアクセスする必要があります。IEnumerableを返そうとすると、次のエラーが発生します
System.Collections.Generic.IEnumerable<AnonymousType#1>
タイプを暗黙的に変換することはできませんSystem.Collections.Generic.List<ProjectModel.Transaction>
エラーは.ToList();の上に表示されます。コードの一部。私は何が間違っているのですか?
コードは次のとおりです。
public static IEnumerable<Transaction>GetAllTransactions()
{
List<Transaction> allTransactions = new List<Transaction>();
using (var context = new CostReportEntities())
{
allTransactions = (from t in context.Transactions
join acc in context.Accounts on t.AccountID equals acc.AccountID
where t.AccountID == acc.AccountID
select new
{
acc.AccountNumber,
t.LocalAmount
}).ToList();
}
return allTransactions;
}