C# – Perform single selection with where

cnetsqlsubsonic

I'd like to achieve the following SQL statement with subsonic 2.2

SELECT Product.* FROM Product WHERE Product.OurPrice <> Product.RetailPrice  

The Subsonic select query I've started with:

SubSonic.SqlQuery select = new SubSonic.Select()
.From<Product>()
.Where(Product.Columns.OurPrice)
.IsNotEqualTo(... object /*Should be Product.Columns.RetailPrice, but that's giving and exception*/...);

My question is how to tell SubSonic 2.2 to generate a where condition against another column in the same table.

Best Answer

It looks like you're trying to compare two columns within your query. This isn't possible in SubSonic 2.2 unless you use an inline query:

http://subsonicproject.com/docs/Inline_Query_Tool

You could also possibly use a view or table based function.