Guid CLSID = New GUID ( " D4ee9c52-8d68-4f33-9485-0926281c78ac " );
Ilist < Guid > IDS = Webproduct. getallchildbyid (CLSID );
VaR Query = DB. t_products.where (P => IDs. Contains (guid) p. f_clsid )); // This statement has no errors during compilation, but an error is reported when it is executed.
The error message is as follows:
The "Boolean contains (system. guid)" method does not support SQL conversion.
It is estimated that. Net's existing LINQ to SQL cannot directly translate the contains method of some types of ilist (such as guid type) into SQL statements.
After studying for a long time, I accidentally found that one of the 100 official examples of LINQ uses arrays to implement in statements and also uses contains, so I switched the ilist <guid> to the guid [] array and tried it. The operation was successful.
VaR query = dB. t_products.where (P =>IDs.Contains (guid) p. f_clsid ));
Changed:
VaR query = dB. t_products.where (P =>IDs. toarray <guid> ().Contains (guid) p. f_clsid ));
In this way, you can get the result normally.
Please indicate the source of the post (net name: Yang Guo/real name: Yang junming MSN: yjmyzy@hotmail.com under the bodhi tree)