1
我有这2个DataTables,customerTableDT
和customerAliasesTableDT
。他们都是从数据库中填充的是这样的:在DataTable上使用LINQ进行内部联接
customerTableDT = UtilityDataAndFunctions.PerformDBReadTransactionDataTableFormat(String.Format("SELECT * FROM {0}", TableNames.customers));
customerAliasesTableDT = UtilityDataAndFunctions.PerformDBReadTransactionDataTableFormat(String.Format("SELECT * FROM {0}", TableNames.customerAliases));
现在,我试图做一个内部连接在两个DataTable这样的:
var customerNames = from customers in customerTableDT.AsEnumerable()
join aliases in customerAliasesTableDT.AsEnumerable on customers.Field<int>("CustomerID") equals aliases.Field<int>("CustomerID")
where aliases.Field<string>("Alias").Contains(iString) select customers.Field<string>("Name")
但它给我这个错误:
The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.
如果我不得不在SQL写什么,我试图做的,它很简单:
SELECT * FROM CUSTOMERS C
INNER JOIN CustomerAliases ALIASES ON ALIASES.CustomerID = C.CustomerID
WHERE CA.Alias LIKE %STRING_HERE%
任何帮助?
哈哈...好找!谢谢 ! – Ahmad 2013-04-27 21:49:11