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.

他のフィールドから試してみました。たとえば、データベースのビット フィールドでは、bool から bit に変換できないと言われています。

結合後の 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 に答える