This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
ObjectContext.txt
180 lines (152 loc) · 4.93 KB
/
ObjectContext.txt
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using System.ComponentModel;
using System.Data.Entity.Core.EntityClient;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Core.Objects.DataClasses;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml.Serialization;
[assembly: EdmSchemaAttribute()]
#region EDM Relationship Metadata
@Each.Association
[assembly: EdmRelationshipAttribute(
"@Model.Namespace",
"@Current.Name",
"@Current.Role1",
System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity.@Current.RelationshipMultiplicity1,
typeof(@Current.Type1),
"@Current.Role2",
System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity.@Current.RelationshipMultiplicity2,
typeof(@Current.Type2),
true)
]
@EndEach
#endregion
namespace @Model.Namespace
{
#region Contexts
@Each.EntityContainer
public class @Current.Name : ObjectContext {
#region Constructors
public @Current.Name() : base("[email protected]", "@Current.Name")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
public @Current.Name(string connectionString) : base(connectionString, "@Current.Name")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
public @Current.Name(EntityConnection connection) : base(connection, "@Current.Name")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
#endregion
#region Partial Methods
partial void OnContextCreated();
#endregion
#region ObjectSet Properties
@Each.EntitySet
public ObjectSet<@Current.EntityType> @Current.Name
{
get {
if ([email protected] == null) {
[email protected] = base.CreateObjectSet<@Current.EntityType>("@Current.Name");
}
return [email protected];
}
}
private ObjectSet<@Current.EntityType> [email protected];
@EndEach
#endregion
#region AddTo Methods
@Each.EntitySet
public void [email protected](@Current.EntityType @Current.Name)
{
base.AddObject("@Current.Name", @Current.Name);
}
@EndEach
#endregion
}
@EndEach
#endregion
#region Entities
@Each.EntityType
[EdmEntityTypeAttribute(NamespaceName="@Model.Namespace", Name="@Current.Name")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public class @Current.Name : EntityObject {
#region Factory Method
public static @Current.Name [email protected](@FuncParam.Property @Current.TypeSigned @Current.Name @EndFuncParam) {
@Current.Name @Current.Name = new @Current.Name();
@Each.Property
@[email protected] = @Current.Name;
@EndEach
return @Current.Name;
}
#endregion
#region Simple Properties
@Each.Property
[EdmScalarPropertyAttribute([email protected], [email protected])]
[DataMemberAttribute()]
public @Current.TypeSigned @Current.Name
{
get
{
return [email protected];
}
set
{
if ([email protected] != value)
{
On@Current[.Name]Changing(value);
ReportPropertyChanging("@Current.Name");
_file = StructuralObject.SetValidValue(value);
ReportPropertyChanged("@Current.Name");
On@Current[.Name]Changed();
}
}
}
private @Current.TypeSigned [email protected];
partial void On@Current[.Name]Changing(@Current.TypeSigned @Current.Name);
partial void On@Current[.Name]Changed();
@EndEach
#endregion
#region Navigation Properties
@Each.NavigationProperty
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("@Model.Namespace", "@Current.ToRole.Name", "@Current.EntityTypeName")]
@If.ToRole.Many
public EntityCollection<@Current.EntityTypeName> @Current.EntityTypeName
@EndIf
@IfNot.ToRole.Many
public @Current.EntityTypeName @Current.EntityTypeName
@EndIf
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<@Current.EntityTypeName>("@[email protected]", "@Current.EntityTypeName");
}
set
{
@If.ToRole.Many
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<@Current.EntityTypeName>("@[email protected]", "@Current.EntityTypeName", value);
}
@EndIf
@IfNot.ToRole.Many
((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<@Current.EntityTypeName>("@[email protected]", "@Current.EntityTypeName").Value = value;
@EndIf
}
}
@EndEach
#endregion
}
@EndEach
#endregion
}