asp.net mvc 4 - Resolving LINQ Error: Missing Query Pattern Implementation -
i receiving strange linq error when trying filter collection in view.
this model:
public class admineditproductspricelistproductsvm { public product product { get; set; } public pricelistproduct pricelistproduct { get; set; } }
this view:
@using pp.lib.models; @using system.linq; @model pplib.viewmodels.admin.admineditproductspricelistproductsvm @{ //get corresponding pricelistproduct pricelistproduct thispp = new proofpixlib.models.pricelistproduct(); thispp = (from x in model.pricelistproduct x.productid == model.product.productid select x).firstordefault(); }
the model.pricelistproduct line underlined in vs , says following error:
could not find implementation of query pattern source type pp.lib.models.pricelistproduct. 'where' not found.
thanks in advance help!
update requested - here code pricelistproduct model.
public partial class pricelistproduct { public pricelistproduct() { this.pricelistproductoptions = new list<pricelistproductoption>(); } [readonly(true)] [display(name = "pricelist product id")] public int pricelistproductid { get; set; } [readonly(true)] [display(name = "pricelist id")] public int pricelistid { get; set; } //foregin key public virtual pricelist pricelist { get; set; } [readonly(true)] [display(name = "product id")] public int productid { get; set; } //foreign key public virtual product product { get; set; } [hiddeninput] public int productcategoryid { get; set; } // not fk data public virtual productcategory productcategory { get; set; } [display(name = "use formula")] private bool _usesformula = true; public bool usesformula { { return _usesformula; } set { _usesformula = value; } } private decimal _price = 0; public decimal price { { return _price; } set { _price = value; } } [display(name = "use discount pricing")] private bool _hasdiscountpricing = false; public bool hasdiscountpricing { { return _hasdiscountpricing; } set { _hasdiscountpricing = value; } } [display(name = "local shipping price")] private decimal _localshipprice = 0; public decimal localshipprice { { return _localshipprice; } set { _localshipprice = value; } } [display(name = "intl. shipping price")] private decimal _intlshipprice = 0; public decimal intlshipprice { { return _intlshipprice; } set { _intlshipprice = value; } } [display(name = "item taxable")] private bool _istaxable = true; public bool istaxable { { return _istaxable; } set { _istaxable = value; } } public virtual list<pricelistproductoption> pricelistproductoptions { get; set; } }
your pricelistproduct
class doesn't implement ienumerable
or iquerable
interfaces, other words it's not collection query on it.
maybe should model.pricelistproduct.pricelistproductoptions
in query or view model should collection?
consecutive assignments don't make sense well:
@{ //get corresponding pricelistproduct pricelistproduct thispp = new proofpixlib.models.pricelistproduct(); thispp = ..; }
Comments
Post a Comment