TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
zeeshan akram
1.4k
325
18k
How to resolve this problem cannot constructed in LING
Mar 3 2020 12:15 AM
Error: System.NotSupportedException: 'The entity or complex type 'ECommercedbModel.ProductDetail' cannot be constructed in a LINQ to Entities query.'
public
ProductViewModel GetProductByID(
int
ID)
{
ProductViewModel listprod =
new
ProductViewModel();
try
{
var productsl = (from p
in
_db.Products
where p.ProductID == ID
select
new
Product
{
PName= p.PName,
PDescription= p.PDescription,
Model= p.Model,
Condition= p.Condition,
UnitPrice=p.UnitPrice,
ManificturedPrice=p.ManificturedPrice,
Discount=p.Discount,
UnitWeight=p.UnitWeight,
UnitInStock=p.UnitInStock
}).FirstOrDefault();
var productD = (from pd
in
_db.ProductDetails
join b
in
_db.Products on pd.ProductID equals b.ProductID
where pd.ProductID == ID
select
new
ProductDetail
{
ProductID =pd.ProductID,
OS=pd.OS,
ProcessorType=pd.ProcessorType,
RAM=pd.RAM,
ScreenSize=pd.ScreenSize,
TouchScreen=pd.TouchScreen,
BatteryLife=pd.BatteryLife,
Camera=pd.Camera
}).ToList();
return
new
ProductViewModel { listProducts = productsl, listProductDetails = productD };
}
catch
(Exception)
{
throw
;
}
}
Reply
Answers (
1
)
How to add the time zone besides to time stamp
what are the languages to learn to be .net developer?