Note that there are some explanatory texts on larger screens.

plurals
  1. POIterating through LinQ to Entities results
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/12916080/the-entity-or-complex-type-cannot-be-constructed-in-a-linq-to-entities-query">The entity or complex type ‘ ’ cannot be constructed in a LINQ to Entities query</a> </p> </blockquote> <p>I asked this question the other day, and actually did not find any answers that worked %100 I'm trying to compare two tables (Incidents and Accounts) and assign Incidents with Matching Customer Id's to Tasks.</p> <pre><code> 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, 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 }).ToArray().Select(x =&gt; new Tasks { creator_id = x.creator_id, start_date = x.start_date, end_date = x.end_date, product_code = x.product_code, os = x.os, details = x.details, solution = x.solution, creator_name = x.creator_name, category = x.category, text = x.text, status_id = x.status_id }); foreach (var item in tasks) { data.Tasks.Add(item); } </code></pre> <p>Here is the Tasks Class</p> <pre><code> public class Tasks { [Key] public int id { get; set; } public string text { get; set; } // [CheckDateAtribute] [Display(Name="Start Date/Time")] [DataType(DataType.DateTime)] public DateTime start_date { get; set; } [DataType(DataType.DateTime)] [Display(Name = "End Date/Time")] public DateTime end_date { get; set; } [Display(Name="Details")] [Required] public string details { get; set; } public int owner_id { get; set; } public int creator_id { get; set; } public int status_id { get; set; } public string reply { get; set; } public string creator_name { get; set; } public string category { get; set; } public string solution { get; set; } public string os { get; set; } public string install_type { get; set; } public string product_code { get; set; } } </code></pre> <p>The Incidents Class</p> <pre><code> 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; } } </code></pre> <p>ANOTHER EDIT: getting a timeout exception now</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload