1:n关系是m:n与F#中的SqlTypeProvider?

时间:2017-06-06 21:03:51

标签: f# type-providers

我的数据库非常简单:

enter image description here

  • 房间位于House。
  • 众议院可以有多个房间。
  • 每个房间只在一个房子里

使用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);

架构由http://sqlcompact.dk/sqldesigner/

生成

0 个答案:

没有答案