我的数据库非常简单:
使用F#SQL类型提供程序,一个Room有多个Houses:
let oneRoom = db.Rooms |> Seq.head
let addressOfHouse = (oneRoom.``dbo.Houses by id`` |> Seq.head ).Address
为什么|> Seq.head
是从一个房间到达住宅地址所必需的?
Sql Schema:
CREATE TABLE [Houses] (
[id] int IDENTITY (1, 1) ,
[Address] nvarchar(255),
PRIMARY KEY ([id])
)
GO
CREATE TABLE [Rooms] (
[id] int IDENTITY (1, 1) ,
[Description] nvarchar(255),
[id_Houses] int,
PRIMARY KEY ([id])
)
GO
ALTER TABLE [Rooms] ADD FOREIGN KEY (id_Houses) REFERENCES [Houses] ([id]);
INSERT INTO Houses VALUES ('Our house, in the middle of the street');
INSERT INTO Houses VALUES ('What a place for us to meet');
INSERT INTO Rooms VALUES ('Bedroom', 1);
INSERT INTO Rooms VALUES ('Bathroom', 1);
INSERT INTO Rooms VALUES ('Kitchen', 2);
生成