Кто-нибудь знает, почему я получаю эту ошибку при попытке редактировать что-то в базе данных через класс ForestLogisticBEAN?Невозможно неявно преобразовать тип 'System.Collections.Generic.List error
Не может неявно преобразовать тип «System.Collections.Generic.List в 'System.Linq.IQueryable'. Явное преобразование существует (вы пропали без вести бросок?)
Вот интеграция слой:
public void EditParcelDetail(ForestLogisticBEAN parcel){
IQueryable<ForestLogisticBEAN> _ForestLogisticsBeans;
_ForestLogisticsBeans = (from order in _context.Orders
from tracking in _context.Trackings
where order.CustomerID == parcel.Id
where tracking.CustomerId == parcel.Id
select new {order.DeliveryDate, order.OrderDate, tracking.Status}).ToList();
}
Вот ForestLogisticBEAN класс:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ForestLogistic.Data.BEANS
{
public class ForestLogisticBEAN
{
public int TrackingId { get; set; }
public int OrderId { get; set; }
public bool Status { get; set; }
public DateTime OrderDate { get; set; }
public DateTime DeliveryDate { get; set; }
public ForestLogisticBEAN() { }
}
}
UPDATE: Я изменил это вместо списка IQueryable, но теперь вместо этой ошибки выбрасывается
модель элемент передается в словарь типа 'System.Collections.Generic.List`1 [ForestLogistics.Data.BEANS.ForestLogisticBEAN], но этот словарь требует модель элемента типа «ForestLogistics.Data .Порядок'.
Вот новая интеграция слой:
public void EditParcelDetail(ForestLogisticBEAN parcel)
{
List<ForestLogisticBEAN> _ForestLogisticsBeans;
_ForestLogisticsBeans = (from order in _context.Orders
from tracking in _context.Trackings
where order.CustomerID == parcel.Id
where tracking.CustomerId == parcel.Id
select new ForestLogisticBEAN {
DeliveryDate = parcel.DeliveryDate,
OrderDate = parcel.OrderDate,
Status = parcel.Status
});
_context.SaveChanges();
}
Цель состоит в том, чтобы иметь возможность совместить заказ и таблицу отслеживания с классом бина
Почему вы объявим его как '' IQueryable вместо 'Список ' или '' IEnumerable ? –
Почему бы не использовать var? 'var _ForestLogisticsBeans = (из заказа в _context.Orders ....' –