当我尝试转换查询时出现错误。这是查询的代码:铸造变量时出错
var query = (from article in db.V_CLIENT_PRIX
where article.CLIENT == Current_Client_Id
select new
{
ID = article.ID,
ARTICLE = article.Article,
REFERENCE = article.Reference,
REMISE = article.Remise,
PRIXVHT = article.PrixVHT,
CLIENT = article.CLIENT,
}
);
我投它是这样的:
ConventionList articlelistconvention = new ConventionList();
articlelistconvention = (ConventionList)query;
这是我model:ConventionList
public class Commandelist
{
public string ARTICLE { get; set; }
public string CIN { get; set; }
public decimal STOCK { get; set; }
public string REFERENCE { get; set; }
public decimal PRIXVHT { get; set; }
public string IMAGE { get; set; }
public double QUANTITE { get; set; }
}
有人可以帮我解决它的代码?
如果他们没有任何关系,你不能投一个对象 – Imad
约定列表或Commandelist?这种投射不会奏效,但您可以实例化一个Commandelist的新实例并映射匹配的属性 – LDJ