Microsoft Lightswitch には、次のような自己参照テーブルがあります。
Courses {CourseID int, ParentID int, CourseName string}
LightSwitch 画面には、リーフ コースのみを表示するドロップダウン ボックスがあります。
LeafCourses クエリを作成し、SQL ステートメントのようなリーフ ノードのみを返すように拡張しようとしています。
SELECT * FROM Courses WHERE CourseId NOT IN
(
SELECT ParentID FROM Courses WHERE ParentID is NOT NULL
)
これは私が持っているものです(動作していません):
partial void LeafCourses_PreprocessQuery(string Parameter, ref IQueryable<Cours> query)
{
query = from Cours c1 in query
where
!(from Cours c2 in this.Courses
select c2.Cours1.CourseId
).Contains(c1.CourseId)
select c1;
}