Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:52:41+00:00 2026-06-02T23:52:41+00:00

I have created a EF 4 & C# to get some data. I am

  • 0

I have created a EF 4 & C# to get some data. I am using Linq. Its as follows:

    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>();

    }

This is causing the following error:

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

Any Idea y am i getting this error??

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:52:43+00:00Added an answer on June 2, 2026 at 11:52 pm

    Resolved

    I had two issues, each of them would cause this error:

    1. I was accessing NULLABLE entity properties without checking if they have value or not. Say CustomerID is NULLABLE, so my query became something like this!

        var query = from c in this.ObjectContext.CallLogs                        
                    select new
                    {
                        CallDescription = c.CallDescription,
                        CustomerID = c.CustomerID.HasValue ? c.CustomerID.Value : 0,
                        CustomerName = c.CustomerID.HasValue ? c.Customer.Name : ""
                    };
    
        if (maximumRows > 0)
            query = query.Skip(startRowIndex).Take(maximumRows);
    
        return query.ToList<object>();
    

    So just check any null value by its HasValue property before accessing it (2nd line in select portion).

    2. I Was also trying to convert integer to string within the select statement. So i just decided that conversion in HTML instead of directly doing it here. This solved my issues.

    Hope this helps someone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created a demo application Using JSF & EJB 3.0 (Stateless session bean
I have created save.plist in a resource folder. I have written some data within
i have created a custom post type named Books & i have a widget
I have created a button in my Android application & I tried to set
I have 3 select boxes and all are having same value (clones) & created
I have a utility class that creates & returns a db connection: Public Shared
For strongly-typed & type-safe solution, I have to do the following step. Create some
I have created a basic site using ASP.NET routing according to Mike Ormond's example
I have written a browser helper object to get the text between the tags
I am trying to extract some data from a private forum. I created a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.