私はここでは少しブロックしていますが、私が最終的にやりたいことは、クエリに基づいてレコードセットを作成し、オブジェクト(Fooと呼ぶ)を作成し、同じIDを持つすべてのFooオブジェクトをArrayListのBarオブジェクトにグループ化するための新しいクエリを作成します。私はLinqからSQLにこれを行う方法はどうですか?既存のクエリからレコードセットを照会するLinq to Sql
public class Foo{
public int id{get;set;}
public string name{get;set;}
}
public class Bar{
public ArrayList foos{get;set;}
}
var query = from tFoo in fooTable join tFoo2 in fooTable2 on tFoo.id equals tFoo2.id
where tFoo2.colour = 'white'
select new Foo
{
id = tFoo.idFoo,
name = tFoo.name
};
var query2 = //iterate the first query and find all Foo objects with the the same
//tFoo.idFoo and store them into Bar objects
最後に、Fooオブジェクトのリストを持つBarオブジェクトのレコードセットが必要です。
ありますか? – cdonner
とIQueryableに色を問い合わせたい場合は、色をFooクラスに追加する必要があります。 – cdonner
arrayListの理由は、各バーに複数のfooがあるということです。 – Ayo