AccountNumberが存在しないトランザクションデータを入力しようとしています。私はそれを得るために、Accountテーブルにアクセスする必要があります。私はIEnumerableを'System.Collections.Generic.IEnumerable <AnonymousType#1>'を 'System.Collections.Generic.List'に暗黙的に変換できません。<modelClass>
が暗黙のうちに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;
}
これは完全に機能しました。優れた答え。正しい方向に私を入れてくれてありがとう。これを使って私は他にもいくつか学んだことがある。今私はViewModelが何であるか知っています。 – shaz