前几天我问了这个问题,实际上没有找到任何有效的答案 %100 我正在尝试比较两个表(事件和帐户)并将具有匹配客户 ID 的事件分配给任务。
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 => 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);
}
这是任务类
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; }
}
事件类
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; }
}
另一个编辑:现在得到一个超时异常