[英]object does not contain a definition for “Properties”
I am getting an error 我收到一个错误
An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Core.dll but was not handled in user code Additional information: 'object' does not contain a definition for 'CategoryId' System.Core.dll中发生类型'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException'的异常,但未在用户代码中处理。其他信息:'对象'不包含'CategoryId'的定义
below is my code 下面是我的代码
dynamic product = (from prod in EntityInitializer.inventoryContext.Products
join sCat in EntityInitializer.inventoryContext.SubCategories on prod.SubCatID equals sCat.SubCategoryId
join vat in EntityInitializer.inventoryContext.VATs on prod.VatID equals vat.VatId
where prod.ProdID == proid && !prod.IsDelete
select new
{
ProductId = prod.ProdID,
CategoryId = sCat.CategoryId,
SubCategoryID = prod.SubCatID,
ProdName = prod.ProdName,
Make = prod.Make,
Finish = prod.ProdFinish,
Price = prod.Price,
Vatid=prod.VatID,
VatValue=vat.VatValue,
Unit = prod.ProdUnit,
Width = prod.ProdWidth,
Depth = prod.ProdDepth,
Height = prod.ProdHeight,
Inch = prod.ProdInch,
ImageURL = prod.ProdImage
}).FirstOrDefault();
I want to retrieve CategoryId from product and product has contain all records which you can easily find in below attached image. 我想从产品中检索CategoryId ,并且产品包含所有记录,您可以在下面的图像中轻松找到这些记录。
http://i.stack.imgur.com/6athN.png http://i.stack.imgur.com/6athN.png
error image http://i.stack.imgur.com/ra0rL.png 错误图片 http://i.stack.imgur.com/ra0rL.png
尝试像这样访问您的财产
product.GetType().GetProperty("CategoryId").GetValue(product, null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.