This project is read-only.
Cartesian product

Category:
TypeProviders.SqlDataConnection
Description: Cartesian product on two tables
Code:
type T0 = Microsoft.FSharp.Data.TypeProviders.SqlDataConnection< "Data Source=localhost;Initial Catalog=FSharpSample;User ID=sa;Password=FSharpSample1234" >

let TypeProvider14() =
let db = T0.GetDataContext();
let q = query {
for n in db.Student do
for m in db.Course do
select (n, m)
}
q |> Seq.iter (fun (student, course) -> printfn "%A %A" student.Name course.CourseName)

Execution Result:
"Lisa" "Math"
"Brent" "Math"
"Anita" "Math"
"Ken" "Math"
"Cathy" "Math"
"Tom" "Math"
"Zeoy" "Math"
"Mark" "Math"
"John" "Math"
"Lisa" "Physics"
"Brent" "Physics"
"Anita" "Physics"
"Ken" "Physics"
"Cathy" "Physics"
"Tom" "Physics"
"Zeoy" "Physics"
"Mark" "Physics"
"John" "Physics"
"Lisa" "Biology"
"Brent" "Biology"
"Anita" "Biology"
"Ken" "Biology"
"Cathy" "Biology"
"Tom" "Biology"
"Zeoy" "Biology"
"Mark" "Biology"
"John" "Biology"
"Lisa" "English"
"Brent" "English"
"Anita" "English"
"Ken" "English"
"Cathy" "English"
"Tom" "English"
"Zeoy" "English"
"Mark" "English"
"John" "English"

Last edited Mar 1, 2012 at 8:04 PM by ttliu2000, version 2

Comments

No comments yet.