Unable to cast den Typ 'System.Int64' to type 'System.Objekt'. LINQ to Entities unterstützt nur casting Entity Data Model primitive Typen

Habe ich eine EF 4 & C#, um einige Daten. Ich bin mit Linq. Seinen Sie wie folgt vor:

    public List<object> GenerateCallTrackingReport(int startRowIndex, int maximumRows, int createdByID)
    {
        var query = from c in this.ObjectContext.CallLogs                        
                    select new
                    {
                        CallLogID = c.CallLogID,
                        DomainName = c.CallDomain.FullName,
                        CreatedByID = c.CreatedByID,
                        CreatedBy = c.CreatedByUser.FirstName + " " + c.CreatedByUser.LastAccessIPN,
                        CalledOn = c.CallDate,
                        IssueResolutionTime = c.IssueResolutionTime,                            
                        CallType = c.CallType.FullName,
                        CallDescription = c.CallDescription,
                        CustomerName = (c.CustomerID > 0 ? c.Customer.FirstName + " " + c.Customer.LastAccessIPN : c.TempCaller.FirstName + " " + c.TempCaller.LastName),
                        CustomerEmail = (c.CustomerID > 0 ? c.Customer.Email : string.Empty),
                        CustomerResponse = c.Response.FullName,
                        IsPending = c.IsPending,
                        NeedFurtherContact = c.NeedFurtherContact
                    };

        if (createdByID > 0)
            query = query.Where(c => c.CreatedByID == createdByID);

        if (maximumRows > 0)
            query = query.Skip(startRowIndex).Take(maximumRows);

        return query.ToList<object>();

    }

Diese verursacht den folgenden Fehler:

Unable to cast the type 'System.Int64' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types.

Jede Idee y bin ich immer diese Fehlermeldung??

Dank

  • Welche Linie ist die Ausnahme?
  • Weil, wie Linq-To-EF arbeiten, sind die Ausnahme wird wahrscheinlich auftreten, in der letzten Zeile, egal wo die Quelle des Problems ist, und größtenteils nutzlos.
InformationsquelleAutor Aamir | 2012-04-23
Schreibe einen Kommentar