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

  • Home
  • SEARCH
  • 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 8683275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:59:50+00:00 2026-06-12T21:59:50+00:00

Possible Duplicate: The entity cannot be constructed in a LINQ to Entities query var

  • 0

Possible Duplicate:
The entity cannot be constructed in a LINQ to Entities query

   var tasks = from i in data.Incidents
                    join a in data.Accounts on i.CustomerID equals a.Acct_CID
                    select new Tasks()
                    {

                        creator_id = a.ID,
                        start_date = i.DateOpened,
                        end_date = i.DateCLosed,
                        product_code = i.ProductCode,
                        install_type = i.InstallType,
                        os = i.OSType,
                        details = i.Description,
                        solution = i.Solution,
                        creator_name = i.TechID,
                        category = i.Title,
                        text = "Ticket for" + " " + i.Name,
                        status_id = 7
                    };

        foreach (var task in tasks)
            data.Tasks.Add(task);
        data.SaveChanges();

 public class Incidents
    {
        [Key]
        public int IncidentID { get; set; }
        public string CustomerID { get; set; }
        public string ProductCode { get; set; }
        public string TechID { get; set; }
        public DateTime DateOpened { get; set; }
        public DateTime DateCLosed { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string Solution { get; set; }
        public string Name { get; set; }
        public string OSType{ get; set; }
        public string InstallType { get; set; }
        public string AddOnSoftware { get; set; }
        public string ScreenShare { get; set; }
    }

gives me an error when I try to iterate, I would love some help with this

  • 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-12T21:59:52+00:00Added an answer on June 12, 2026 at 9:59 pm

    In Linq-to-Entities you can only project to an anonymous type or a regular class. You can’t project to an existing entity type. You can with linq-to-objects like so

    var tasks = (from i in data.Incidents
                join a in data.Accounts on i.CustomerID equals a.Acct_CID
                 select new
                 {
                   creator_id = a.ID,
                   start_date = i.DateOpened,
                   end_date = i.DateCLosed
                  // ...
                 }).AsEnumerable().Select(x => new Tasks {
                   creator_id = x.creator_id,
                   start_date = x.start_date,
                   end_date = x.end_date              
                 }).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Entity Framework Code First: decimal precision I'm using Linq-to-Entities with the EntityFramework
Possible Duplicate: LINQ to Entities does not recognize the method I use Entity Framework
Possible Duplicate: Exclude a field/property from the database with Entity Framework 4 & Code-First
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Conditional Linq Queries Using Entity Framework 4.0 I have a search condition
Possible Duplicate: What is the best way to compare two entity framework entities? I
Possible Duplicate: Entity Framework Include() strongly typed Ok, I've got an entity framework query
Possible Duplicate: Using Entity Framework entities as business objects? I'm looking into using Entity
Possible Duplicate: How to do SQL Like % in Linq? Like Operator in Entity
Possible Duplicate: ASP.NET MVC - Linq to Entities model as the ViewModel - is

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.