[英]Select Linq cannot implicitly convert type byte[] to System.web.httpPostedFileBase
I am trying to do a linq select which join multiple table and 1 of the table consist of a byte data type. 我试图做一个linq select联接多个表和表的1组成一个字节数据类型。
My ViewModel is as per below: 我的ViewModel如下所示:
public class ServiceRequestsViewModel
{
public HttpPostedFileBase Attachment { get; set; }
}
My controller is as per below: 我的控制器如下:
public IEnumerable<ServiceRequestsViewModel> ServiceRequestGetAll()
{
var result = (from srv in DB.Services
join srq in DB.ServiceRequests on srv.Id equals srq.ServiceId
join srp in DB.ServiceApprovers on srq.ServiceId equals srp.ServiceId
select new ServiceRequestsViewModel
{
Id = srq.Id,
ServiceId = srq.ServiceId,
RequestorId = srq.RequestorId,
ApproverId = srp.UserId,
Name = srv.Name,
Description = srq.Description,
Status = srq.Status,
Attachment = srq.Attachment,
CreatedBy = srq.CreatedBy,
CreatedDate = srq.CreatedDate
})
;
return result.GroupBy(x => x.Id).Select(group => group.FirstOrDefault()).OrderByDescending(a => a.Status).ThenByDescending(b => b.CreatedDate);
}
For the Attachment = srq.Attachment, I encounter the error: Cannot implicitly convert type byte[] to System.Web.HttpPostedFileBase. 对于Attachment = srq.Attachment,我遇到了错误:无法将类型byte []隐式转换为System.Web.HttpPostedFileBase。
HttpPostedFileBase
is a wrapper class so you can access the data that your client uploaded with this call . HttpPostedFileBase
是包装器类,因此您可以访问客户端通过此调用上传的数据。
You are not in that scenario with your call. 您不在那种情况下。
Your data is already in your database. 您的数据已经在数据库中。 You need to pick a different datatype to return that data to your client. 您需要选择其他数据类型以将该数据返回给客户端。 byte[]
(that you already have) might be fine for your case, we cannot know, that's your job to decide. byte[]
(您已经拥有)可能适合您的情况,我们不知道,这是您要决定的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.