Compartir a través de


Member Access (M to SQL Mapping)

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

Member access in Microsoft code name “M” operates over a single entity. It has several permutations depending on the type of the field you are accessing.

Operation “M” Example SQL Example

Member Access: Scalar

A.field
select field as [Item] from A

Member Access: Scalar Collection

A.field

Not currently implemented.

Member Access: Entity

A.field
select <entity columns>
   from <entity storage table> as [t0]
      inner join A as [t1] on [t1].field = [t0].[Id];

(For entities with multiple identity fields, the on statement compares multiple columns.)

Member Access: Entity Collection

A.field

Not currently implemented.

Entity and entity collection member access retrieves the entities, including all of their fields, from the table where the entities are stored.

Member Access: Entity

module M {
    type Var {
        Id : Integer32;
        name : Names;
        i : Integer32;
    } where identity(Id);
    type Name {
        Id : Integer32;
        j : Integer32;
    } where identity(Id);
    Names : Name*;
    SingleVar : Var;
    F() { SingleVar.name }
}
create table [M].[Names]
(
  [Id] int not null,
  [j] int not null,
  constraint [PK_Names] primary key clustered ([Id])
);
create table [M].[SingleVar]
(
  [Id] int not null,
  [name] int not null,
  [i] int not null,
  constraint [PK_SingleVar] primary key clustered ([Id]),
  constraint [FK_SingleVar_name_M_Names] foreign key ([name]) references [M].[Names] ([Id])
);
create view [M].[F]
(
  [Id],
  [j]
)
as
  select [t0].[Id] as [Id], [t0].[j] as [j]from [M].[Names] as [t0]inner join [M].[SingleVar] as [t1] on [t1].[name] = [t0].[Id];