Nie można niejawnie przekonwertować typu „System.Collections.Generic.IEnumerable <AnonymousType # 1>” na „System.Collections.Generic.List <modelClass> [duplikat]

To pytanie ma już tutaj odpowiedź:

Nie można niejawnie przekonwertować typu „System.Collections.Generic.IEnumerable <AnonymousType # 1>” na „System.Collections.Generic.List <string> 5 odpowiedzi

Próbuję zapełnić dane transakcji, w których numer konta nie istnieje. Muszę uzyskać dostęp do tabeli Konto, aby to uzyskać. Otrzymuję następujący błąd, w którym próbuję zwrócić IEnumerable

Nie można niejawnie przekonwertować typuSystem.Collections.Generic.IEnumerable<AnonymousType#1> doSystem.Collections.Generic.List<ProjectModel.Transaction>

Błąd jest wyświetlany na górze.Notować(); część kodu. Co ja robię źle?

kod to:

    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;

    }

questionAnswers(2)

yourAnswerToTheQuestion