そのため、同じint変数の順序付きリストにあるint変数でクエリを順序付けようとしています。たとえば、クエリはアイテムのリストの順序で並べ替える必要があります。各データコンテキストは異なるデータベースからのものであるため、最初のクエリをペット名の順序に基づいてIDの順序付きリストにします。2番目のクエリのデータフィールドからはペットIDのみを使用できます。クエリは次のようになります。
using (ListDataContext syndb = new ListDataContext())
{
using (QueryDataContext ledb = new QueryDataContext())
{
// Set the order of pets by name and make a list of the pet id's
var stp = syndb.StoredPets.OrderBy(x => x.Name).Select(x => x.PetID).ToList();
// Reorder the SoldPets query using the ordered list of pet id's
var slp = ledb.SoldPets.OrderBy(x => stp.IndexOf(x.petId)).Select(x => x);
// do something with the query
}
}
2番目のクエリは、「メソッド'Int32 IndexOf(Int32)'にはSQLへの変換がサポートされていません」というメッセージを表示します。エラー、私が必要なことをする方法はありますか?