可以在亚音速中执行以下操作。
SELECT * FROM TABLE1
在哪里Column1> Column2或Column1< Colum3
我见过的所有示例都假设您现在要传递给where子句。我试图在不创建视图的情况下这样做。
由于
答案 0 :(得分:2)
如果它在我们的堆栈中我找不到它:)。尽管添加:)会是一件好事。到目前为止,您可以使用内联查询来执行您编写的语句(它采用直接SQL)。我知道这很难看但是......
瑞克 - 如果你确实这样做了,我会对如何工作感兴趣。 “Col2”将尝试解析为某种类型,您的查询将失败。答案 1 :(得分:0)
看来此功能不在当前版本中,但已提交到下一版本的代码中。
答案 2 :(得分:0)
如果您使用的是SubSonic 2.1 / 2.2,并且可以访问该来源,则可以应用以下内容:
的亚音速/类SqlQuery / Constraint.cs 强>
(添加新属性)
public bool ParameterIsTableColumn
{
get { return ParameterValue is TableSchema.TableColumn ; }
}
的亚音速/类SqlQuery / SqlQuery.cs 强>
(在SetConstraintParams方法内)
foreach(Constraint c in qry.Constraints)
{
if (c.ConstructionFragment == "##" || c.ParameterIsTableColumn)
continue;
的亚音速/类SqlQuery / SqlGenerators / ANSISqlGenerator.cs 强>
(内部BuildConstraintSQL方法)
//add this at the top of the method
int currentConstraintIndex = query.Constraints.IndexOf(c);
///the statement 'c.ParameterName = ' occurs four times in this method
///use this line the first three times, and a slight variation of it on the fourth
c.ParameterName = (c.ParameterIsTableColumn ? ((TableSchema.TableColumn)c.ParameterValue).QualifiedName : String.Concat(col.ParameterName, currentConstraintIndex));
答案 3 :(得分:-1)
是的。
Dim TableList As Generic.List(Of Database.Table1) = _
New SubSonic.Select().From("Table1"). _
Where("Col1").IsGreaterThan("Col2"). _
Or("Col1").IsLessThan("Col3").ExecuteTypedList(Of Database.Table1)()