0

对于那些在亚音速方面表现不错的人!

        TblNewsCollection col =
            new Select().From(Tables.TblNews)
                .InnerJoin(Tables.TblContent)
                .Paged(currentPage, pageSize)
                .OrderDesc(TblContent.Columns.PubDate)
                .ExecuteAsCollection<TblNewsCollection>();

以上工作,没问题,但是当我尝试添加 where 子句时

        TblNewsCollection col =
            new Select().From(Tables.TblNews)
                .InnerJoin(Tables.TblContent)
                .Where(TblContent.Columns.UserFK)
                .IsEqualTo(guidUserFK)
                .Paged(currentPage, pageSize)
                .OrderDesc(TblContent.Columns.PubDate)
                .ExecuteAsCollection<TblNewsCollection>();

我收到这条消息

System.InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) 
System.InvalidCastException: Failed to convert parameter value from a Guid to a String.

我已经从其他字段尝试过,例如数据库中的一个位字段,它说它不能从布尔转换为位!

似乎只是连接后 where 语句的问题

4

2 回答 2

1

我发现使用上面的 Northwind 示例中的 TableColumnSchema 而不是列名可以更好地进行连接。

于 2009-01-16T06:25:47.857 回答
0
Northwind.CustomerCollection customersByCategory = new Select()
    .From(Northwind.Customer.Schema)
    .InnerJoin(Northwind.Order.Schema)
    .InnerJoin(Northwind.OrderDetail.OrderIDColumn, Northwind.Order.OrderIDColumn)
    .InnerJoin(Northwind.Product.ProductIDColumn, Northwind.OrderDetail.ProductIDColumn)
    .Where("CategoryID").IsEqualTo(5)
    .ExecuteAsCollection<Northwind.CustomerCollection>();

有一个应该有效的例子。如果这有助于任何人帮助我!

于 2008-11-18T12:33:24.653 回答