I have a table called FILTRE_LINKLER and column's names are
- ID
- SEF_URL
- CONDITIONS
For example,
- ID=1
- SEF_URL="test/"
- CONDITIONS="STOCK>50"`
I want to get CONDITIONS part to linq where clause.
var product = (from d in db.PRODUCTS
where *CONDITIONS from DB*
select new ProductModel
{
Description= d.DESCRIPTION,
Brand= d.BRANDS.BRAND,
SefUrl = sef_url,
Name= d.NAME,
});
I try to that:
var query = db.FILTRE_LINKLER.Select(x => x.CONDITIONS);
var product = (from d in db.PRODUCTS
where query
select new ProductModel
{
Description= d.DESCRIPTION,
Brand= d.BRANDS.BRAND,
SefUrl = sef_url,
Name= d.NAME,
});
But I have an error that is Cannot implicitly convert type 'System.Linq.IQueryable' to bool.
I edited because "Problem Solved". For solution:
Download Install-Package System.Linq.Dynamic -Version 1.0.7 (said me @StepUp) then add to class
using System.Linq.Dynamic;
then following code like that,
var whereCondition = db.FILTRE_LINKLER.Select(x => x.CONDITIONS).FirstOrDefault();
var product = (from d in db.PRODUCTS
where query
select new ProductModel
{
Description= d.DESCRIPTION,
Brand= d.BRANDS.BRAND,
SefUrl = sef_url,
Name= d.NAME,
}).Where(whereCondition);

.Where()call. egif (useColor) { query=query.Where(product=>product.Color='Red'); }STOCKcomes from in yourCONDITIONS?