Windows Azure Cloud Storage ermöglicht es Ihnen bereits ab 0,10€ pro GB/Monat die Vorteile der Cloud zu nutzen.
Hypercell ein ] Hypercell aus ] Zeige Navigation ] Verstecke Navigation ]
c++.de  
   
Advanced Developers Conference     
Bücher-Shop mit Amazon (Buchkategorien)C++ : Referenzen zu C++ : C++ Builder : Visual C++ : C# : Java : Spieleprogrammierung : Systemprogrammierung Linux : Software-Entwicklung : .NET : Compilertechnik : Algorithmen & Datenstrukturen : Objektorientierung : Entwurfsmuster : UML : eXtreme Programming : Scrum : Projektmanagement : Software-Testing : Datenbanken : Tom DeMarco : Dilbert : User Friendly
C/C++ Forum :: C# und .NET ::  DataGrid als Row für DataGrid  
Gehen Sie zu Seite Zurück  1, 2
  Zeige alle Beiträge auf einer Seite
Auf Beitrag antworten
Autor Nachricht
witte
Mitglied

Benutzerprofil
Anmeldungsdatum: 08.01.2008
Beiträge: 1295
Beitrag witte Mitglied 12:07:41 31.08.2010   Titel:              Zitieren

Also ich habe das jetzt mal in einem Konsolenanwendung nachvollzogen. Allerdings nicht über ria sondern klassisch.

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TableB](
    [bID] [int] IDENTITY(1,1) NOT NULL,
    [bName] [varchar](32) NOT NULL,
 CONSTRAINT [PK_bID] PRIMARY KEY CLUSTERED
(
    [bID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TableA](
    [aID] [int] IDENTITY(1,1) NOT NULL,
    [aName] [varchar](32) NOT NULL,
 CONSTRAINT [PK_aID] PRIMARY KEY CLUSTERED
(
    [aID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TableA_TableB](
    [aID] [int] NOT NULL,
    [bID] [int] NOT NULL,
 CONSTRAINT [PK_Group_Module] PRIMARY KEY CLUSTERED
(
    [aID] ASC,
    [bID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[TableA_TableB]  WITH CHECK ADD  CONSTRAINT [FK_TableA_TableB_TableA] FOREIGN KEY([aID])
REFERENCES [dbo].[TableA] ([aID])
GO
ALTER TABLE [dbo].[TableA_TableB] CHECK CONSTRAINT [FK_TableA_TableB_TableA]
GO
ALTER TABLE [dbo].[TableA_TableB]  WITH CHECK ADD  CONSTRAINT [FK_TableA_TableB_TableB] FOREIGN KEY([bID])
REFERENCES [dbo].[TableB] ([bID])
GO
ALTER TABLE [dbo].[TableA_TableB] CHECK CONSTRAINT [FK_TableA_TableB_TableB]
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TableB](
[bID] [int] IDENTITY(1,1) NOT NULL,
[bName] [varchar](32) NOT NULL,
CONSTRAINT [PK_bID] PRIMARY KEY CLUSTERED
(
[bID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TableA](
[aID] [int] IDENTITY(1,1) NOT NULL,
[aName] [varchar](32) NOT NULL,
CONSTRAINT [PK_aID] PRIMARY KEY CLUSTERED
(
[aID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TableA_TableB](
[aID] [int] NOT NULL,
[bID] [int] NOT NULL,
CONSTRAINT [PK_Group_Module] PRIMARY KEY CLUSTERED
(
[aID] ASC,
[bID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[TableA_TableB] WITH CHECK ADD CONSTRAINT [FK_TableA_TableB_TableA] FOREIGN KEY([aID])
REFERENCES [dbo].[TableA] ([aID])
GO
ALTER TABLE [dbo].[TableA_TableB] CHECK CONSTRAINT [FK_TableA_TableB_TableA]
GO
ALTER TABLE [dbo].[TableA_TableB] WITH CHECK ADD CONSTRAINT [FK_TableA_TableB_TableB] FOREIGN KEY([bID])
REFERENCES [dbo].[TableB] ([bID])
GO
ALTER TABLE [dbo].[TableA_TableB] CHECK CONSTRAINT [FK_TableA_TableB_TableB]
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TableB](
    [bID] [int] IDENTITY(1,1) NOT NULL,
    [bName] [varchar](32) NOT NULL,
 CONSTRAINT [PK_bID] PRIMARY KEY CLUSTERED
(
    [bID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TableA](
    [aID] [int] IDENTITY(1,1) NOT NULL,
    [aName] [varchar](32) NOT NULL,
 CONSTRAINT [PK_aID] PRIMARY KEY CLUSTERED
(
    [aID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TableA_TableB](
    [aID] [int] NOT NULL,
    [bID] [int] NOT NULL,
 CONSTRAINT [PK_Group_Module] PRIMARY KEY CLUSTERED
(
    [aID] ASC,
    [bID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[TableA_TableB]  WITH CHECK ADD  CONSTRAINT [FK_TableA_TableB_TableA] FOREIGN KEY([aID])
REFERENCES [dbo].[TableA] ([aID])
GO
ALTER TABLE [dbo].[TableA_TableB] CHECK CONSTRAINT [FK_TableA_TableB_TableA]
GO
ALTER TABLE [dbo].[TableA_TableB]  WITH CHECK ADD  CONSTRAINT [FK_TableA_TableB_TableB] FOREIGN KEY([bID])
REFERENCES [dbo].[TableB] ([bID])
GO
ALTER TABLE [dbo].[TableA_TableB] CHECK CONSTRAINT [FK_TableA_TableB_TableB]


Dann habe ich ein Entity Data Model hinzugefügt und dort die beiden Tabellen importiert. Das XML was automatisch generiert wird)
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema Namespace="TestModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
        <EntityContainer Name="TestModelStoreContainer">
          <EntitySet Name="TableA" EntityType="TestModel.Store.TableA" store:Type="Tables" Schema="dbo" />
          <EntitySet Name="TableA_TableB" EntityType="TestModel.Store.TableA_TableB" store:Type="Tables" Schema="dbo" />
          <EntitySet Name="TableB" EntityType="TestModel.Store.TableB" store:Type="Tables" Schema="dbo" />
          <AssociationSet Name="FK_TableA_TableB_TableA" Association="TestModel.Store.FK_TableA_TableB_TableA">
            <End Role="TableA" EntitySet="TableA" />
            <End Role="TableA_TableB" EntitySet="TableA_TableB" />
          </AssociationSet>
          <AssociationSet Name="FK_TableA_TableB_TableB" Association="TestModel.Store.FK_TableA_TableB_TableB">
            <End Role="TableB" EntitySet="TableB" />
            <End Role="TableA_TableB" EntitySet="TableA_TableB" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="TableA">
          <Key>
            <PropertyRef Name="aID" />
          </Key>
          <Property Name="aID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="aName" Type="varchar" Nullable="false" MaxLength="32" />
        </EntityType>
        <EntityType Name="TableA_TableB">
          <Key>
            <PropertyRef Name="aID" />
            <PropertyRef Name="bID" />
          </Key>
          <Property Name="aID" Type="int" Nullable="false" />
          <Property Name="bID" Type="int" Nullable="false" />
        </EntityType>
        <EntityType Name="TableB">
          <Key>
            <PropertyRef Name="bID" />
          </Key>
          <Property Name="bID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="bName" Type="varchar" Nullable="false" MaxLength="32" />
        </EntityType>
        <Association Name="FK_TableA_TableB_TableA">
          <End Role="TableA" Type="TestModel.Store.TableA" Multiplicity="1" />
          <End Role="TableA_TableB" Type="TestModel.Store.TableA_TableB" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="TableA">
              <PropertyRef Name="aID" />
            </Principal>
            <Dependent Role="TableA_TableB">
              <PropertyRef Name="aID" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
        <Association Name="FK_TableA_TableB_TableB">
          <End Role="TableB" Type="TestModel.Store.TableB" Multiplicity="1" />
          <End Role="TableA_TableB" Type="TestModel.Store.TableA_TableB" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="TableB">
              <PropertyRef Name="bID" />
            </Principal>
            <Dependent Role="TableA_TableB">
              <PropertyRef Name="bID" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="TestModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
        <EntityContainer Name="TestEntities" annotation:LazyLoadingEnabled="true">
          <EntitySet Name="TableAs" EntityType="TestModel.TableA" />
          <EntitySet Name="TableBs" EntityType="TestModel.TableB" />
          <AssociationSet Name="TableA_TableB" Association="TestModel.TableA_TableB">
            <End Role="TableA" EntitySet="TableAs" />
            <End Role="TableB" EntitySet="TableBs" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="TableA">
          <Key>
            <PropertyRef Name="aID" />
          </Key>
          <Property Name="aID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="aName" Type="String" Nullable="false" MaxLength="32" Unicode="false" FixedLength="false" />
          <NavigationProperty Name="TableBs" Relationship="TestModel.TableA_TableB" FromRole="TableA" ToRole="TableB" />
        </EntityType>
        <EntityType Name="TableB">
          <Key>
            <PropertyRef Name="bID" />
          </Key>
          <Property Name="bID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="bName" Type="String" Nullable="false" MaxLength="32" Unicode="false" FixedLength="false" />
          <NavigationProperty Name="TableAs" Relationship="TestModel.TableA_TableB" FromRole="TableB" ToRole="TableA" />
        </EntityType>
        <Association Name="TableA_TableB">
          <End Role="TableA" Type="TestModel.TableA" Multiplicity="*" />
          <End Role="TableB" Type="TestModel.TableB" Multiplicity="*" />
        </Association>
      </Schema>
    </edmx:ConceptualModels>
    <!-- C-S mapping content -->
    <edmx:Mappings>
      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
        <EntityContainerMapping StorageEntityContainer="TestModelStoreContainer" CdmEntityContainer="TestEntities">
          <EntitySetMapping Name="TableAs"><EntityTypeMapping TypeName="TestModel.TableA"><MappingFragment StoreEntitySet="TableA">
            <ScalarProperty Name="aID" ColumnName="aID" />
            <ScalarProperty Name="aName" ColumnName="aName" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <EntitySetMapping Name="TableBs"><EntityTypeMapping TypeName="TestModel.TableB"><MappingFragment StoreEntitySet="TableB">
            <ScalarProperty Name="bID" ColumnName="bID" />
            <ScalarProperty Name="bName" ColumnName="bName" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <AssociationSetMapping Name="TableA_TableB" TypeName="TestModel.TableA_TableB" StoreEntitySet="TableA_TableB">
            <EndProperty Name="TableA">
              <ScalarProperty Name="aID" ColumnName="aID" />
            </EndProperty>
            <EndProperty Name="TableB">
              <ScalarProperty Name="bID" ColumnName="bID" />
            </EndProperty>
          </AssociationSetMapping>
        </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>
  </edmx:Runtime>
  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
  <Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
    <Connection>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
      </DesignerInfoPropertySet>
    </Connection>
    <Options>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="ValidateOnBuild" Value="true" />
        <DesignerProperty Name="EnablePluralization" Value="False" />
        <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
      </DesignerInfoPropertySet>
    </Options>
    <!-- Diagram content (shape and connector positions) -->
    <Diagrams>
      <Diagram Name="Model1">
        <EntityTypeShape EntityType="TestModel.TableA" Width="1.5" PointX="0.75" PointY="0.875" Height="1.427958984375" IsExpanded="true" />
        <EntityTypeShape EntityType="TestModel.TableB" Width="1.5" PointX="3" PointY="0.875" Height="1.4279589843749996" IsExpanded="true" />
        <AssociationConnector Association="TestModel.TableA_TableB" ManuallyRouted="false">
          <ConnectorPoint PointX="2.25" PointY="1.5889794921874998" />
          <ConnectorPoint PointX="3" PointY="1.5889794921874998" />
        </AssociationConnector>
      </Diagram>
    </Diagrams>
  </Designer>
</edmx:Edmx>
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="TestModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="TestModelStoreContainer">
<EntitySet Name="TableA" EntityType="TestModel.Store.TableA" store:Type="Tables" Schema="dbo" />
<EntitySet Name="TableA_TableB" EntityType="TestModel.Store.TableA_TableB" store:Type="Tables" Schema="dbo" />
<EntitySet Name="TableB" EntityType="TestModel.Store.TableB" store:Type="Tables" Schema="dbo" />
<AssociationSet Name="FK_TableA_TableB_TableA" Association="TestModel.Store.FK_TableA_TableB_TableA">
<End Role="TableA" EntitySet="TableA" />
<End Role="TableA_TableB" EntitySet="TableA_TableB" />
</AssociationSet>
<AssociationSet Name="FK_TableA_TableB_TableB" Association="TestModel.Store.FK_TableA_TableB_TableB">
<End Role="TableB" EntitySet="TableB" />
<End Role="TableA_TableB" EntitySet="TableA_TableB" />
</AssociationSet>
</EntityContainer>
<EntityType Name="TableA">
<Key>
<PropertyRef Name="aID" />
</Key>
<Property Name="aID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="aName" Type="varchar" Nullable="false" MaxLength="32" />
</EntityType>
<EntityType Name="TableA_TableB">
<Key>
<PropertyRef Name="aID" />
<PropertyRef Name="bID" />
</Key>
<Property Name="aID" Type="int" Nullable="false" />
<Property Name="bID" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="TableB">
<Key>
<PropertyRef Name="bID" />
</Key>
<Property Name="bID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="bName" Type="varchar" Nullable="false" MaxLength="32" />
</EntityType>
<Association Name="FK_TableA_TableB_TableA">
<End Role="TableA" Type="TestModel.Store.TableA" Multiplicity="1" />
<End Role="TableA_TableB" Type="TestModel.Store.TableA_TableB" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="TableA">
<PropertyRef Name="aID" />
</Principal>
<Dependent Role="TableA_TableB">
<PropertyRef Name="aID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_TableA_TableB_TableB">
<End Role="TableB" Type="TestModel.Store.TableB" Multiplicity="1" />
<End Role="TableA_TableB" Type="TestModel.Store.TableA_TableB" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="TableB">
<PropertyRef Name="bID" />
</Principal>
<Dependent Role="TableA_TableB">
<PropertyRef Name="bID" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="TestModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="TestEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="TableAs" EntityType="TestModel.TableA" />
<EntitySet Name="TableBs" EntityType="TestModel.TableB" />
<AssociationSet Name="TableA_TableB" Association="TestModel.TableA_TableB">
<End Role="TableA" EntitySet="TableAs" />
<End Role="TableB" EntitySet="TableBs" />
</AssociationSet>
</EntityContainer>
<EntityType Name="TableA">
<Key>
<PropertyRef Name="aID" />
</Key>
<Property Name="aID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="aName" Type="String" Nullable="false" MaxLength="32" Unicode="false" FixedLength="false" />
<NavigationProperty Name="TableBs" Relationship="TestModel.TableA_TableB" FromRole="TableA" ToRole="TableB" />
</EntityType>
<EntityType Name="TableB">
<Key>
<PropertyRef Name="bID" />
</Key>
<Property Name="bID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="bName" Type="String" Nullable="false" MaxLength="32" Unicode="false" FixedLength="false" />
<NavigationProperty Name="TableAs" Relationship="TestModel.TableA_TableB" FromRole="TableB" ToRole="TableA" />
</EntityType>
<Association Name="TableA_TableB">
<End Role="TableA" Type="TestModel.TableA" Multiplicity="*" />
<End Role="TableB" Type="TestModel.TableB" Multiplicity="*" />
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="TestModelStoreContainer" CdmEntityContainer="TestEntities">
<EntitySetMapping Name="TableAs"><EntityTypeMapping TypeName="TestModel.TableA"><MappingFragment StoreEntitySet="TableA">
<ScalarProperty Name="aID" ColumnName="aID" />
<ScalarProperty Name="aName" ColumnName="aName" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<EntitySetMapping Name="TableBs"><EntityTypeMapping TypeName="TestModel.TableB"><MappingFragment StoreEntitySet="TableB">
<ScalarProperty Name="bID" ColumnName="bID" />
<ScalarProperty Name="bName" ColumnName="bName" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<AssociationSetMapping Name="TableA_TableB" TypeName="TestModel.TableA_TableB" StoreEntitySet="TableA_TableB">
<EndProperty Name="TableA">
<ScalarProperty Name="aID" ColumnName="aID" />
</EndProperty>
<EndProperty Name="TableB">
<ScalarProperty Name="bID" ColumnName="bID" />
</EndProperty>
</AssociationSetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="False" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams>
<Diagram Name="Model1">
<EntityTypeShape EntityType="TestModel.TableA" Width="1.5" PointX="0.75" PointY="0.875" Height="1.427958984375" IsExpanded="true" />
<EntityTypeShape EntityType="TestModel.TableB" Width="1.5" PointX="3" PointY="0.875" Height="1.4279589843749996" IsExpanded="true" />
<AssociationConnector Association="TestModel.TableA_TableB" ManuallyRouted="false">
<ConnectorPoint PointX="2.25" PointY="1.5889794921874998" />
<ConnectorPoint PointX="3" PointY="1.5889794921874998" />
</AssociationConnector>
</Diagram>
</Diagrams>
</Designer>
</edmx:Edmx>
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema Namespace="TestModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
        <EntityContainer Name="TestModelStoreContainer">
          <EntitySet Name="TableA" EntityType="TestModel.Store.TableA" store:Type="Tables" Schema="dbo" />
          <EntitySet Name="TableA_TableB" EntityType="TestModel.Store.TableA_TableB" store:Type="Tables" Schema="dbo" />
          <EntitySet Name="TableB" EntityType="TestModel.Store.TableB" store:Type="Tables" Schema="dbo" />
          <AssociationSet Name="FK_TableA_TableB_TableA" Association="TestModel.Store.FK_TableA_TableB_TableA">
            <End Role="TableA" EntitySet="TableA" />
            <End Role="TableA_TableB" EntitySet="TableA_TableB" />
          </AssociationSet>
          <AssociationSet Name="FK_TableA_TableB_TableB" Association="TestModel.Store.FK_TableA_TableB_TableB">
            <End Role="TableB" EntitySet="TableB" />
            <End Role="TableA_TableB" EntitySet="TableA_TableB" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="TableA">
          <Key>
            <PropertyRef Name="aID" />
          </Key>
          <Property Name="aID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="aName" Type="varchar" Nullable="false" MaxLength="32" />
        </EntityType>
        <EntityType Name="TableA_TableB">
          <Key>
            <PropertyRef Name="aID" />
            <PropertyRef Name="bID" />
          </Key>
          <Property Name="aID" Type="int" Nullable="false" />
          <Property Name="bID" Type="int" Nullable="false" />
        </EntityType>
        <EntityType Name="TableB">
          <Key>
            <PropertyRef Name="bID" />
          </Key>
          <Property Name="bID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="bName" Type="varchar" Nullable="false" MaxLength="32" />
        </EntityType>
        <Association Name="FK_TableA_TableB_TableA">
          <End Role="TableA" Type="TestModel.Store.TableA" Multiplicity="1" />
          <End Role="TableA_TableB" Type="TestModel.Store.TableA_TableB" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="TableA">
              <PropertyRef Name="aID" />
            </Principal>
            <Dependent Role="TableA_TableB">
              <PropertyRef Name="aID" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
        <Association Name="FK_TableA_TableB_TableB">
          <End Role="TableB" Type="TestModel.Store.TableB" Multiplicity="1" />
          <End Role="TableA_TableB" Type="TestModel.Store.TableA_TableB" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="TableB">
              <PropertyRef Name="bID" />
            </Principal>
            <Dependent Role="TableA_TableB">
              <PropertyRef Name="bID" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="TestModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
        <EntityContainer Name="TestEntities" annotation:LazyLoadingEnabled="true">
          <EntitySet Name="TableAs" EntityType="TestModel.TableA" />
          <EntitySet Name="TableBs" EntityType="TestModel.TableB" />
          <AssociationSet Name="TableA_TableB" Association="TestModel.TableA_TableB">
            <End Role="TableA" EntitySet="TableAs" />
            <End Role="TableB" EntitySet="TableBs" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="TableA">
          <Key>
            <PropertyRef Name="aID" />
          </Key>
          <Property Name="aID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="aName" Type="String" Nullable="false" MaxLength="32" Unicode="false" FixedLength="false" />
          <NavigationProperty Name="TableBs" Relationship="TestModel.TableA_TableB" FromRole="TableA" ToRole="TableB" />
        </EntityType>
        <EntityType Name="TableB">
          <Key>
            <PropertyRef Name="bID" />
          </Key>
          <Property Name="bID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="bName" Type="String" Nullable="false" MaxLength="32" Unicode="false" FixedLength="false" />
          <NavigationProperty Name="TableAs" Relationship="TestModel.TableA_TableB" FromRole="TableB" ToRole="TableA" />
        </EntityType>
        <Association Name="TableA_TableB">
          <End Role="TableA" Type="TestModel.TableA" Multiplicity="*" />
          <End Role="TableB" Type="TestModel.TableB" Multiplicity="*" />
        </Association>
      </Schema>
    </edmx:ConceptualModels>
    <!-- C-S mapping content -->
    <edmx:Mappings>
      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
        <EntityContainerMapping StorageEntityContainer="TestModelStoreContainer" CdmEntityContainer="TestEntities">
          <EntitySetMapping Name="TableAs"><EntityTypeMapping TypeName="TestModel.TableA"><MappingFragment StoreEntitySet="TableA">
            <ScalarProperty Name="aID" ColumnName="aID" />
            <ScalarProperty Name="aName" ColumnName="aName" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <EntitySetMapping Name="TableBs"><EntityTypeMapping TypeName="TestModel.TableB"><MappingFragment StoreEntitySet="TableB">
            <ScalarProperty Name="bID" ColumnName="bID" />
            <ScalarProperty Name="bName" ColumnName="bName" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <AssociationSetMapping Name="TableA_TableB" TypeName="TestModel.TableA_TableB" StoreEntitySet="TableA_TableB">
            <EndProperty Name="TableA">
              <ScalarProperty Name="aID" ColumnName="aID" />
            </EndProperty>
            <EndProperty Name="TableB">
              <ScalarProperty Name="bID" ColumnName="bID" />
            </EndProperty>
          </AssociationSetMapping>
        </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>
  </edmx:Runtime>
  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
  <Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
    <Connection>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
      </DesignerInfoPropertySet>
    </Connection>
    <Options>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="ValidateOnBuild" Value="true" />
        <DesignerProperty Name="EnablePluralization" Value="False" />
        <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
      </DesignerInfoPropertySet>
    </Options>
    <!-- Diagram content (shape and connector positions) -->
    <Diagrams>
      <Diagram Name="Model1">
        <EntityTypeShape EntityType="TestModel.TableA" Width="1.5" PointX="0.75" PointY="0.875" Height="1.427958984375" IsExpanded="true" />
        <EntityTypeShape EntityType="TestModel.TableB" Width="1.5" PointX="3" PointY="0.875" Height="1.4279589843749996" IsExpanded="true" />
        <AssociationConnector Association="TestModel.TableA_TableB" ManuallyRouted="false">
          <ConnectorPoint PointX="2.25" PointY="1.5889794921874998" />
          <ConnectorPoint PointX="3" PointY="1.5889794921874998" />
        </AssociationConnector>
      </Diagram>
    </Diagrams>
  </Designer>
</edmx:Edmx>


Dann der Code in der main
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            ObservableCollection<TableA> entities;

            using (var ctx = new TestEntities()) {

                entities = new ObservableCollection<TableA>(ctx.TableAs.Include("TableBs"));
            }

            foreach (var tableA in entities) {

                Console.WriteLine(tableA.aName);

                foreach (var tableB in tableA.TableBs) {

                    Console.WriteLine("  " + tableB.bName);
                }
            }
        }
    }
}
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

ObservableCollection<TableA> entities;

using (var ctx = new TestEntities()) {

entities = new ObservableCollection<TableA>(ctx.TableAs.Include("TableBs"));
}

foreach (var tableA in entities) {

Console.WriteLine(tableA.aName);

foreach (var tableB in tableA.TableBs) {

Console.WriteLine(" " + tableB.bName);
}
}
}
}
}
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            ObservableCollection<TableA> entities;

            using (var ctx = new TestEntities()) {

                entities = new ObservableCollection<TableA>(ctx.TableAs.Include("TableBs"));
            }

            foreach (var tableA in entities) {

                Console.WriteLine(tableA.aName);

                foreach (var tableB in tableA.TableBs) {

                    Console.WriteLine("  " + tableB.bName);
                }
            }
        }
    }
}


... gibt die gewünschten Beziehungen aus.
FrEEzE2046
Mitglied

Benutzerprofil
Anmeldungsdatum: 03.12.2008
Beiträge: 786
Beitrag FrEEzE2046 Mitglied 09:09:06 01.09.2010   Titel:              Zitieren

witte schrieb:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

ObservableCollection<TableA> entities;

using (var ctx = new TestEntities()) {

entities = new ObservableCollection<TableA>(ctx.TableAs.Include("TableBs"));
}

foreach (var tableA in entities) {

Console.WriteLine(tableA.aName);

foreach (var tableB in tableA.TableBs) {

Console.WriteLine(" " + tableB.bName);
}
}
}
}
}
[/cs]

... gibt die gewünschten Beziehungen aus.


Hi,

ich hab das jetzt mal exakt genau so gemacht wie du, nur eben innerhalb meines DomainServices. Die Beziehung zwischen TableA und TableB ist weiterhin aID == bID was natürlich absoluter Blödsinn ist.

Die Assoziation die gesetzt wurde, scheint für mich korrekt zu sein.


EDIT:
Okay, in einer Konsolen-Applikation bekomme ich nun auch die korrekte Beziehung ausgegeben. Offensichtlich liegt der Fehler im DomainService.

Ich habe dort in der Klasse von TableA folgendes definiert:
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[MetadataTypeAttribute(typeof(TableA.TableAMetadata))]
public partial class TableA
{
    internal sealed class TableAMetadata
    {

        // Metadata classes are not meant to be instantiated.
        private TableAMetadata()
        {
        }

        public int aID { get; set; }

        [Association("TableA_TableB", "aID", "bID"), Include()]
        public EntityCollection<TableB> TableBs { get; set; }

        public string aName { get; set; }
    }
}
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[MetadataTypeAttribute(typeof(TableA.TableAMetadata))]
public partial class TableA
{
internal sealed class TableAMetadata
{

// Metadata classes are not meant to be instantiated.
private TableAMetadata()
{
}

public int aID { get; set; }

[Association("TableA_TableB", "aID", "bID"), Include()]
public EntityCollection<TableB> TableBs { get; set; }

public string aName { get; set; }
}
}
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[MetadataTypeAttribute(typeof(TableA.TableAMetadata))]
public partial class TableA
{
    internal sealed class TableAMetadata
    {

        // Metadata classes are not meant to be instantiated.
        private TableAMetadata()
        {
        }

        public int aID { get; set; }

        [Association("TableA_TableB", "aID", "bID"), Include()]
        public EntityCollection<TableB> TableBs { get; set; }

        public string aName { get; set; }
    }
}


Zuletzt bearbeitet von FrEEzE2046 am 09:16:43 01.09.2010, insgesamt 1-mal bearbeitet
FrEEzE2046
Mitglied

Benutzerprofil
Anmeldungsdatum: 03.12.2008
Beiträge: 786
Beitrag FrEEzE2046 Mitglied 09:23:37 01.09.2010   Titel:              Zitieren

Ich denke ich habe den Fehler gefunden. Meine Definition war einfach Quatsch:
Dies wäre die korrekte Association:

Association("TableA_TableB", "aID", "aID").

Die Referenz ist meiner eigenen Klasse ist natürlich aID. Der Fremdschlüssel jedoch ebenfalls ;-)

Rein theoretisch scheint nun alles korrekt zu sein, jedoch bekomme ich folgende Fehlermeldung:

Code:
Association named 'TableA_TableB' defined on entity type 'MyApplication.Web.Models.TableA' is invalid: OtherKey property named 'aID' cannot be found on entity type 'MyApplication.Web.Models.TableB'.
Code:
Association named 'TableA_TableB' defined on entity type 'MyApplication.Web.Models.TableA' is invalid: OtherKey property named 'aID' cannot be found on entity type 'MyApplication.Web.Models.TableB'.
Code:
Association named 'TableA_TableB' defined on entity type 'MyApplication.Web.Models.TableA' is invalid: OtherKey property named 'aID' cannot be found on entity type 'MyApplication.Web.Models.TableB'.


Die Aussage der Fehlermeldung ist natürlich korrekt, jedoch frage ich mich warum er überhaupt in TableB danach sucht und nicht in der Cross Table?!
witte
Mitglied

Benutzerprofil
Anmeldungsdatum: 08.01.2008
Beiträge: 1295
Beitrag witte Mitglied 11:59:06 01.09.2010   Titel:              Zitieren

Im Entity Data Model gibt es ein Spezialfall der hier zutrifft. Zwischen den Entities gibt es Relationsobjekte die über die Entity Keys die Beziehungen der Objekte zueinander beschreiben. Normalerweise wäre es so:
Code:
TableA <-RelationAAB-> TableAB <-RelationABB-> TableB
Code:
TableA <-RelationAAB-> TableAB <-RelationABB-> TableB
Code:
TableA <-RelationAAB-> TableAB <-RelationABB-> TableB

Also wie die Tabellen und Fremdschlüsselbeziehungen in der DB sind. Nun gibt es aber den Sonderfall. Wenn TableAB
* die beiden Fremdschlüssel als ihren Primärschlüssel definiert
* kein weiteres Attribut sich in der Tabelle befindet
kann das Entity TableAB entfallen weil die dazwischenliegende Relation mächtig genug ist diese Beziehung auszudrücken
Code:
TableA <-RelationAB-> TableB
Code:
TableA <-RelationAB-> TableB
Code:
TableA <-RelationAB-> TableB

Exakt aus diesem Grund kannst du von TableA nach TableB navigieren. Würdest du nur ein Attribut in TableAB hinzufügen und das Modell neu generieren würde es ganz anders laufen.
Möglicherweise solltest du deshalb gleich eine Assoziation nach TableB bauen aber ich kenne mich mit diesen Service-Objekten nicht aus.
FrEEzE2046
Mitglied

Benutzerprofil
Anmeldungsdatum: 03.12.2008
Beiträge: 786
Beitrag FrEEzE2046 Mitglied 20:40:09 01.09.2010   Titel:              Zitieren

Danke für deine Antwort.
Ich sehe schon, es gibt keinen anderen Weg als ein Dummy-Feld einzuführen. Die habe ich nun getan und kann meine join table nun auch im Model sehen.
Nun schaffe ich es jedoch nicht die Association korrekt zu definieren.

Sieht nun also so aus:

SQL-Datenbank:
TableA
Code:
    - aID int identity(1,1) not null
    - aName varchar(32) identity(1,1) not null
Code:
- aID int identity(1,1) not null
- aName varchar(32) identity(1,1) not null
Code:
    - aID int identity(1,1) not null
    - aName varchar(32) identity(1,1) not null


TableB
Code:
    - bID int not null
    - bName varchar(32) not null
Code:
- bID int not null
- bName varchar(32) not null
Code:
    - bID int not null
    - bName varchar(32) not null


TableA_B
Code:
    - aID int
    - bID int
    - Dummy bit
Code:
- aID int
- bID int
- Dummy bit
Code:
    - aID int
    - bID int
    - Dummy bit


DomainService Meta-Klassen:
TableA
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    [MetadataTypeAttribute(typeof(TableA.TableAMetadata))]
    public partial class TableA
    {
        internal sealed class TableAMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private TableAMetadata()
            {
            }

            [Include(), Association("TableA", "aID", "aID")]
            public EntityCollection<Group_Module> Group_Module { get; set; }

            public int aID { get; set; }

            public string aName { get; set; }
        }
    }
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[MetadataTypeAttribute(typeof(TableA.TableAMetadata))]
public partial class TableA
{
internal sealed class TableAMetadata
{

// Metadata classes are not meant to be instantiated.
private TableAMetadata()
{
}

[Include(), Association("TableA", "aID", "aID")]
public EntityCollection<Group_Module> Group_Module { get; set; }

public int aID { get; set; }

public string aName { get; set; }
}
}
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    [MetadataTypeAttribute(typeof(TableA.TableAMetadata))]
    public partial class TableA
    {
        internal sealed class TableAMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private TableAMetadata()
            {
            }

            [Include(), Association("TableA", "aID", "aID")]
            public EntityCollection<Group_Module> Group_Module { get; set; }

            public int aID { get; set; }

            public string aName { get; set; }
        }
    }


TableB
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    [MetadataTypeAttribute(typeof(TableA_B.TableA_BMetadata))]
    public partial class TableA_B
    {
        internal sealed class TableA_BMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private TableA_BMetadata()
            {
            }

            public TableA TableA { get; set; }

            public int aID { get; set; }

            public Nullable<bool> Dummy { get; set; }

            [Include(), Association("FK_TableA_B_TableB", "bID", "bID")]
            public TableB TableB { get; set; }

            public int bID { get; set; }
        }
    }
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[MetadataTypeAttribute(typeof(TableA_B.TableA_BMetadata))]
public partial class TableA_B
{
internal sealed class TableA_BMetadata
{

// Metadata classes are not meant to be instantiated.
private TableA_BMetadata()
{
}

public TableA TableA { get; set; }

public int aID { get; set; }

public Nullable<bool> Dummy { get; set; }

[Include(), Association("FK_TableA_B_TableB", "bID", "bID")]
public TableB TableB { get; set; }

public int bID { get; set; }
}
}
C# Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    [MetadataTypeAttribute(typeof(TableA_B.TableA_BMetadata))]
    public partial class TableA_B
    {
        internal sealed class TableA_BMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private TableA_BMetadata()
            {
            }

            public TableA TableA { get; set; }

            public int aID { get; set; }

            public Nullable<bool> Dummy { get; set; }

            [Include(), Association("FK_TableA_B_TableB", "bID", "bID")]
            public TableB TableB { get; set; }

            public int bID { get; set; }
        }
    }


Die Query im DomainService sieht nun so aus:
C# Code:
        public IQueryable<TableA> GetTableAsWithAssociatedTableBs()
        {
            return this.ObjectContext.TableAs.Include("FK_TableA_B_TableB").Include("TableB").ToList().AsQueryable();
C# Code:
public IQueryable<TableA> GetTableAsWithAssociatedTableBs()
{
return this.ObjectContext.TableAs.Include("FK_TableA_B_TableB").Include("TableB").ToList().AsQueryable();
C# Code:
        public IQueryable<TableA> GetTableAsWithAssociatedTableBs()
        {
            return this.ObjectContext.TableAs.Include("FK_TableA_B_TableB").Include("TableB").ToList().AsQueryable();

}

Leider wird nichts inkludiert ...
witte
Mitglied

Benutzerprofil
Anmeldungsdatum: 08.01.2008
Beiträge: 1295
Beitrag witte Mitglied 11:30:15 03.09.2010   Titel:              Zitieren

FrEEzE2046 schrieb:
Die Query im DomainService sieht nun so aus:
C# Code:
        public IQueryable<TableA> GetTableAsWithAssociatedTableBs()
        {
            return this.ObjectContext.TableAs.Include("FK_TableA_B_TableB").Include("TableB").ToList().AsQueryable();
C# Code:
public IQueryable<TableA> GetTableAsWithAssociatedTableBs()
{
return this.ObjectContext.TableAs.Include("FK_TableA_B_TableB").Include("TableB").ToList().AsQueryable();
C# Code:
        public IQueryable<TableA> GetTableAsWithAssociatedTableBs()
        {
            return this.ObjectContext.TableAs.Include("FK_TableA_B_TableB").Include("TableB").ToList().AsQueryable();

}

Leider wird nichts inkludiert ...
Das Chaining funktioniert so nicht. Das wird jetzt so verstanden dass TableA zwei NavProperties hat, eine zu FK_TableA_B_TableB und eine zu TableB. Du meinst wahrscheinlich
C# Code:
this.ObjectContext.TableAs.Include("FK_TableA_B_TableB.TableB")
C# Code:
this.ObjectContext.TableAs.Include("FK_TableA_B_TableB.TableB")
C# Code:
this.ObjectContext.TableAs.Include("FK_TableA_B_TableB.TableB")
wenn FK_TableA_B_TableB tatsächlich ein NavProperty ist.
C/C++ Forum :: C# und .NET ::  DataGrid als Row für DataGrid  
Gehen Sie zu Seite Zurück  1, 2
Auf Beitrag antworten

Zeige alle Beiträge auf einer Seite




Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Sie können Beiträge in dieses Forum schreiben.
Sie können auf Beiträge in diesem Forum antworten.
Sie können Ihre Beiträge in diesem Forum nicht bearbeiten.
Sie können Ihre Beiträge in diesem Forum nicht löschen.
Sie können an Umfragen in diesem Forum nicht mitmachen.

Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme

c++.de ist Teilnehmer des Partnerprogramms von Amazon Europe S.à.r.l. und Partner des Werbeprogramms, das zur Bereitstellung eines Mediums für Websites konzipiert wurde, mittels dessen durch die Platzierung von Werbeanzeigen und Links zu amazon.de Werbekostenerstattung verdient werden kann.

Die Vervielfältigung der auf den Seiten www.c-plusplus.de, www.c-plusplus.info, www.c-sar.de, www.c-plusplus.net und www.baeckmann.de enthaltenen Informationen ohne eine schriftliche Genehmigung des Seitenbetreibers ist untersagt (vgl. §4 Urheberrechtsgesetz). Die Nutzung und Änderung der vorgestellten Strukturen und Verfahren in privaten und kommerziellen Softwareanwendungen ist ausdrücklich erlaubt, soweit keine Rechte Dritter verletzt werden. Der Seitenbetreiber übernimmt keine Gewähr für die Funktion einzelner Beiträge oder Programmfragmente, insbesondere übernimmt er keine Haftung für eventuelle aus dem Gebrauch entstehenden Folgeschäden.