Using Dynamic Linq to set column name

dynamic-linq linq vb.net

Question

I have a database that is a little inverted. For every project row, there are columns for different Engineers involved. (architect engineer, construction engineer, mechanical engineer). I need to get a list of projects that are assigned to one person. So to do that, I need to write a query that will search for their job title in the columns based on a drop down list. I am using Dynamic Linq and I have written a query like this

Dim db As New DesignConstructionDataContext
Dim query = db.all_drawings.Where("@0 = Kevin O'lausen", "ddlJobTitle.value").Select("ProjectNumber").toList

But when I run this, the eror I get says "=" is not compatible with string values. and when I try using "is" instead, it says it needs to be a boolean value. I am very green to this Dynamic linq thing, any help would be great!

1
1
11/24/2014 12:23:08 PM

Popular Answer

Methiks you a bit confused with linq.
So, as i understand

  1. you have field name in ddlJobTitle.value, and
  2. try check this field with value "Kevin O'lausen"

So you need change your query like

Dim query = db.all_drawings.Where(ddlJobTitle.value + " = @0", "Kevin O'lausen").Select("ProjectNumber").toList
0
4/20/2015 6:36:37 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow