3

可以在亚音速下进行以下操作。

从表 1 中选择 *

WHERE Column1 > Column2 或 Column1 < Colum3

我见过的所有示例都假定您现在将一个值传递给 where 子句。我正在尝试在不创建视图的情况下执行此操作。

谢谢

4

4 回答 4

2

如果它在我们的堆栈中,我找不到它:)。不过,添加将是一件好事:)。现在,您可以使用内联查询来简单地执行您编写的语句(它需要直接的 SQL)。我知道这很丑但是...

瑞克 - 如果你真的让它工作,我会对如何工作感兴趣。“Col2”将尝试解析为一种类型,您的查询将失败。

于 2009-04-04T19:10:35.543 回答
0

如果您使用的是 SubSonic 2.1/2.2 并且您可以访问源代码,则可以应用以下内容:

SubSonic/SqlQuery/Constraint.cs
(添加新属性)

public bool ParameterIsTableColumn
{
    get { return ParameterValue is TableSchema.TableColumn ;  }
}

SubSonic/SqlQuery/SqlQuery.cs
(在 SetConstraintParams 方法内)

foreach(Constraint c in qry.Constraints)
{
    if (c.ConstructionFragment == "##" || c.ParameterIsTableColumn)
        continue;

SubSonic/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));
于 2011-01-01T14:06:28.640 回答
0

看来此功能不在当前版本中,但已提交到下一个版本的代码中。

于 2008-10-29T04:09:00.570 回答
-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)()
于 2009-04-04T10:49:11.350 回答