2008-11-18 96 views
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转换为位!

似乎只是在加入

回答

1

我发现使用TableColumnSchema可以更好地工作,就像在上面的Northwind示例中那样,而不是列名。

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>(); 

有,理应工作的例子声明后,其中的问题。如果这有助于任何人帮助我!