ruby_odata 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/.gitignore +9 -3
  2. data/.travis.yml +4 -0
  3. data/CHANGELOG.rdoc +18 -1
  4. data/README.rdoc +77 -19
  5. data/config/cucumber.yml +4 -3
  6. data/features/basic_auth.feature +5 -7
  7. data/features/batch_request.feature +11 -11
  8. data/features/complex_types.feature +11 -11
  9. data/features/query_builder.feature +27 -18
  10. data/features/service.feature +8 -8
  11. data/features/service_manage.feature +27 -12
  12. data/features/service_methods.feature +37 -0
  13. data/features/ssl.feature +4 -4
  14. data/features/step_definitions/pickle_steps.rb +100 -0
  15. data/features/step_definitions/service_steps.rb +99 -65
  16. data/features/support/constants.rb +3 -0
  17. data/features/support/custom_helpers.rb +54 -0
  18. data/features/support/env.rb +0 -10
  19. data/features/support/hooks.rb +1 -1
  20. data/features/support/pickle.rb +82 -0
  21. data/features/type_conversion.feature +10 -10
  22. data/lib/ruby_odata.rb +4 -1
  23. data/lib/ruby_odata/association.rb +36 -0
  24. data/lib/ruby_odata/class_builder.rb +96 -16
  25. data/lib/ruby_odata/helpers.rb +10 -0
  26. data/lib/ruby_odata/operation.rb +7 -5
  27. data/lib/ruby_odata/property_metadata.rb +11 -6
  28. data/lib/ruby_odata/query_builder.rb +20 -1
  29. data/lib/ruby_odata/service.rb +407 -94
  30. data/lib/ruby_odata/version.rb +1 -1
  31. data/ruby_odata.gemspec +2 -0
  32. data/spec/association_spec.rb +48 -0
  33. data/spec/class_builder_spec.rb +11 -2
  34. data/spec/fixtures/inheritance/edmx_pluralsight.xml +111 -0
  35. data/spec/fixtures/inheritance/result_pluralsight_courses.xml +229 -0
  36. data/spec/fixtures/links/result_links_query.xml +6 -0
  37. data/spec/fixtures/partial/partial_feed_metadata.xml +25 -0
  38. data/spec/fixtures/partial/partial_feed_part_1.xml +42 -0
  39. data/spec/fixtures/partial/partial_feed_part_2.xml +42 -0
  40. data/spec/fixtures/partial/partial_feed_part_3.xml +40 -0
  41. data/spec/fixtures/sample_service/edmx_categories_products.xml +1 -0
  42. data/spec/fixtures/sample_service/result_category_names.xml +5 -0
  43. data/spec/fixtures/sample_service/result_entity_category_web_get.xml +29 -0
  44. data/spec/fixtures/sample_service/result_entity_single_category_web_get.xml +23 -0
  45. data/spec/fixtures/sample_service/result_first_category_id.xml +2 -0
  46. data/spec/fixtures/sample_service/result_multiple_category_products.xml +57 -0
  47. data/spec/fixtures/sample_service/result_single_category.xml +18 -0
  48. data/spec/fixtures/sample_service/result_single_product.xml +26 -0
  49. data/spec/fixtures/sample_service/result_single_product_not_found.xml +4 -0
  50. data/spec/fixtures/sap/edmx_sap_demo_flight.xml +62 -58
  51. data/spec/property_metadata_spec.rb +9 -2
  52. data/spec/query_builder_spec.rb +11 -0
  53. data/spec/revised_service_spec.rb +197 -0
  54. data/spec/service_spec.rb +463 -4
  55. data/test/RubyODataService/RubyODataService.sln +20 -0
  56. data/test/RubyODataService/RubyODataService/App_Start/EntityFramework.SqlServerCompact.cs +12 -0
  57. data/test/RubyODataService/RubyODataService/BasicAuth/RubyOData.svc +3 -0
  58. data/test/RubyODataService/RubyODataService/BasicAuth/RubyOData.svc.cs +107 -0
  59. data/test/RubyODataService/RubyODataService/Global.asax +1 -0
  60. data/test/RubyODataService/RubyODataService/Global.asax.cs +49 -0
  61. data/test/RubyODataService/RubyODataService/Models/AuditFields.cs +16 -0
  62. data/test/RubyODataService/RubyODataService/Models/Category.cs +16 -0
  63. data/test/RubyODataService/RubyODataService/Models/Product.cs +20 -0
  64. data/test/RubyODataService/RubyODataService/Properties/AssemblyInfo.cs +35 -0
  65. data/test/RubyODataService/RubyODataService/RubyOData.svc +3 -0
  66. data/test/RubyODataService/RubyODataService/RubyOData.svc.cs +57 -0
  67. data/test/RubyODataService/RubyODataService/RubyODataContext.cs +16 -0
  68. data/test/RubyODataService/RubyODataService/RubyODataService.csproj +159 -0
  69. data/test/RubyODataService/RubyODataService/RubyODataService.csproj.user +31 -0
  70. data/test/RubyODataService/RubyODataService/Web.Debug.config +30 -0
  71. data/test/RubyODataService/RubyODataService/Web.Release.config +31 -0
  72. data/test/RubyODataService/RubyODataService/Web.config +27 -0
  73. data/test/RubyODataService/RubyODataService/bin/EntityFramework.dll +0 -0
  74. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Edm.dll +0 -0
  75. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.OData.dll +0 -0
  76. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Services.Client.dll +0 -0
  77. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Services.dll +0 -0
  78. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Spatial.dll +0 -0
  79. data/test/RubyODataService/RubyODataService/bin/RubyODataService.dll +0 -0
  80. data/test/RubyODataService/RubyODataService/bin/System.Data.SqlServerCe.Entity.dll +0 -0
  81. data/test/RubyODataService/RubyODataService/bin/System.Data.SqlServerCe.dll +0 -0
  82. data/test/RubyODataService/RubyODataService/bin/System.Spatial.dll +0 -0
  83. data/test/RubyODataService/RubyODataService/bin/WebActivator.dll +0 -0
  84. data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  85. data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  86. data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  87. data/test/RubyODataService/RubyODataService/bin/amd64/sqlcecompact40.dll +0 -0
  88. data/test/RubyODataService/RubyODataService/bin/amd64/sqlceer40EN.dll +0 -0
  89. data/test/RubyODataService/RubyODataService/bin/amd64/sqlceme40.dll +0 -0
  90. data/test/RubyODataService/RubyODataService/bin/amd64/sqlceqp40.dll +0 -0
  91. data/test/RubyODataService/RubyODataService/bin/amd64/sqlcese40.dll +0 -0
  92. data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  93. data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  94. data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  95. data/test/RubyODataService/RubyODataService/bin/x86/sqlcecompact40.dll +0 -0
  96. data/test/RubyODataService/RubyODataService/bin/x86/sqlceer40EN.dll +0 -0
  97. data/test/RubyODataService/RubyODataService/bin/x86/sqlceme40.dll +0 -0
  98. data/test/RubyODataService/RubyODataService/bin/x86/sqlceqp40.dll +0 -0
  99. data/test/RubyODataService/RubyODataService/bin/x86/sqlcese40.dll +0 -0
  100. data/test/RubyODataService/RubyODataService/packages.config +7 -0
  101. data/test/RubyODataService/packages/EntityFramework.4.2.0.0/EntityFramework.4.2.0.0.nupkg +0 -0
  102. data/test/RubyODataService/packages/EntityFramework.4.2.0.0/lib/net40/EntityFramework.dll +0 -0
  103. data/test/RubyODataService/packages/EntityFramework.4.2.0.0/lib/net40/EntityFramework.xml +13488 -0
  104. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/Content/App_Start/EntityFramework.SqlServerCompact.cs.pp +12 -0
  105. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/EULA_ENU.rtf +969 -0
  106. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/EntityFramework.SqlServerCompact.4.1.8482.2.nupkg +0 -0
  107. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/lib/System.Data.SqlServerCe.Entity.dll +0 -0
  108. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/tools/install.ps1 +3 -0
  109. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Content/web.config.transform +8 -0
  110. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  111. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  112. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  113. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlcecompact40.dll +0 -0
  114. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceer40EN.dll +0 -0
  115. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceme40.dll +0 -0
  116. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceqp40.dll +0 -0
  117. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlcese40.dll +0 -0
  118. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  119. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  120. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  121. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlcecompact40.dll +0 -0
  122. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceer40EN.dll +0 -0
  123. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceme40.dll +0 -0
  124. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceqp40.dll +0 -0
  125. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlcese40.dll +0 -0
  126. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/SQLCE_EULA_ENU.rtf +778 -0
  127. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/SqlServerCompact.4.0.8482.1.nupkg +0 -0
  128. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/GetSqlCEPostBuildCmd.ps1 +12 -0
  129. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/install.ps1 +11 -0
  130. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/uninstall.ps1 +9 -0
  131. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/lib/System.Data.SqlServerCe.dll +0 -0
  132. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/DataSvcUtil.exe +0 -0
  133. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/License.rtf +708 -0
  134. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Edm.dll +0 -0
  135. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Edm.xml +4150 -0
  136. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.OData.dll +0 -0
  137. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.OData.xml +1969 -0
  138. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Client.dll +0 -0
  139. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Client.xml +1442 -0
  140. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Design.dll +0 -0
  141. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Design.xml +191 -0
  142. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.dll +0 -0
  143. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.xml +2559 -0
  144. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Spatial.dll +0 -0
  145. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Spatial.xml +15 -0
  146. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.VsDesigner.DataServices.Adapter.dll +0 -0
  147. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/README.txt +6 -0
  148. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/System.Spatial.dll +0 -0
  149. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/System.Spatial.xml +2276 -0
  150. data/test/RubyODataService/packages/WebActivator.1.0.0.0/WebActivator.1.0.0.0.nupkg +0 -0
  151. data/test/RubyODataService/packages/WebActivator.1.0.0.0/lib/WebActivator.dll +0 -0
  152. data/test/RubyODataService/packages/repositories.config +4 -0
  153. data/test/applicationhost.config.template +2 -2
  154. data/test/blueprints.rb +5 -4
  155. data/test/iisExpress x64.bat b/data/test/iisExpress → x64.bat +0 -0
  156. data/test/iisExpress x86.bat b/data/test/iisExpress → x86.bat +0 -0
  157. data/test/setpath.rb +13 -3
  158. data/test/usage_samples/querying.rb +45 -0
  159. data/test/usage_samples/reflection.rb +16 -0
  160. data/test/usage_samples/sample_data.rb +30 -0
  161. metadata +327 -36
  162. data/test/Cassini x64.bat +0 -1
  163. data/test/Cassini x86.bat +0 -1
  164. data/test/SampleService/App_Code/AuditFields.cs +0 -13
  165. data/test/SampleService/App_Code/Entities.cs +0 -145
  166. data/test/SampleService/App_Code/Model.Designer.cs +0 -578
  167. data/test/SampleService/App_Code/Model.edmx +0 -157
  168. data/test/SampleService/App_Code/ModelContainerExtended.cs +0 -32
  169. data/test/SampleService/App_Data/_TestDB.mdf +0 -0
  170. data/test/SampleService/App_Data/_TestDB_Log.ldf +0 -0
  171. data/test/SampleService/BasicAuth/Entities.svc +0 -1
  172. data/test/SampleService/Entities.svc +0 -1
  173. data/test/SampleService/web.config +0 -37
@@ -1 +0,0 @@
1
- "%ProgramFiles(x86)%\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE" /port:8989 /path:"%~dp0SampleService" /vpath:"/SampleService"
@@ -1 +0,0 @@
1
- "%ProgramFiles%\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE" /port:8989 /path:"%~dp0SampleService" /vpath:"/SampleService"
@@ -1,13 +0,0 @@
1
- using System;
2
-
3
- namespace Model
4
- {
5
- public partial class AuditFields
6
- {
7
- public AuditFields()
8
- {
9
- CreateDate = DateTime.UtcNow;
10
- ModifiedDate = DateTime.UtcNow;
11
- }
12
- }
13
- }
@@ -1,145 +0,0 @@
1
- using System.Data.Services;
2
- using System.Data.Services.Common;
3
- using System.ServiceModel;
4
- using System.ServiceModel.Web;
5
- using System.Web;
6
- using System;
7
- using System.Linq;
8
- using System.Security.Principal;
9
- using System.Text;
10
- using Model;
11
-
12
- [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
13
- public class Entities : DataService< ModelContainer >
14
- {
15
- // This method is called only once to initialize service-wide policies.
16
- public static void InitializeService(DataServiceConfiguration config)
17
- {
18
- config.SetEntitySetAccessRule("*", EntitySetRights.All);
19
- config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
20
- config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
21
- config.UseVerboseErrors = true;
22
- }
23
-
24
- /// <summary>
25
- /// Cleans the database for testing.
26
- /// </summary>
27
- [WebInvoke]
28
- public void CleanDatabaseForTesting()
29
- {
30
- var context = new ModelContainer();
31
- context.ExecuteStoreCommand("ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_CategoryProduct]");
32
- context.ExecuteStoreCommand("TRUNCATE TABLE [dbo].[Categories]; TRUNCATE TABLE [dbo].[Products]");
33
- context.ExecuteStoreCommand("ALTER TABLE [dbo].[Products] ADD CONSTRAINT [FK_CategoryProduct] FOREIGN KEY ([Category_Id]) REFERENCES [dbo].[Categories]([Id])");
34
-
35
- }
36
-
37
- protected override void OnStartProcessingRequest(ProcessRequestArgs args)
38
- {
39
- base.OnStartProcessingRequest(args);
40
- if (args.RequestUri.AbsoluteUri.ToLower().EndsWith("cleandatabasefortesting"))
41
- {
42
- var hostAddress = HttpContext.Current.Request.UserHostAddress;
43
- if (hostAddress != "127.0.0.1" && hostAddress != "::1")
44
- throw new DataServiceException(401, "Access Denied");
45
- }
46
- }
47
- }
48
-
49
- public class OurBasicAuthenticationModule: IHttpModule
50
- {
51
- public void Init(HttpApplication context)
52
- {
53
- context.AuthenticateRequest
54
- += new EventHandler(context_AuthenticateRequest);
55
- }
56
-
57
- void context_AuthenticateRequest(object sender, EventArgs e)
58
- {
59
- HttpApplication application = (HttpApplication)sender;
60
-
61
- // Only require authentication if BasicAuth is in the URI path
62
- if (( application.Context.Request.Url.AbsoluteUri.Contains("BasicAuth")) &&
63
- (!CustomBasicAuthenticationProvider.Authenticate(application.Context)))
64
- {
65
- application.Context.Response.Status = "401 Unauthorized";
66
- application.Context.Response.StatusCode = 401;
67
- application.Context.Response.AddHeader("WWW-Authenticate", "Basic");
68
- application.CompleteRequest();
69
- }
70
- }
71
-
72
- public void Dispose() { }
73
-
74
- } // class OurBasicAuthenticationModule: IHttpModule
75
-
76
- public class CustomBasicAuthenticationProvider
77
- {
78
- public static bool Authenticate(HttpContext context)
79
- {
80
- if (!HttpContext.Current.Request.Headers.AllKeys.Contains("Authorization"))
81
- return false;
82
-
83
- string authHeader = HttpContext.Current.Request.Headers["Authorization"];
84
-
85
- IPrincipal principal;
86
- if (TryGetPrincipal(authHeader, out principal))
87
- {
88
- HttpContext.Current.User = principal;
89
- return true;
90
- }
91
- return false;
92
- }
93
-
94
- private static bool TryGetPrincipal(string authHeader, out IPrincipal principal)
95
- {
96
- var creds = ParseAuthHeader(authHeader);
97
- if (creds != null && TryGetPrincipal(creds, out principal))
98
- return true;
99
-
100
- principal = null;
101
- return false;
102
- }
103
-
104
- private static bool TryGetPrincipal(string[] creds,out IPrincipal principal)
105
- {
106
- if (creds[0] == "admin" && creds[1] == "passwd")
107
- {
108
- principal = new GenericPrincipal(
109
- new GenericIdentity("Administrator"),
110
- new string[] {"Administrator", "User"}
111
- );
112
- return true;
113
- }
114
- else
115
- {
116
- principal = null;
117
- return false;
118
- }
119
- }
120
-
121
- private static string[] ParseAuthHeader(string authHeader)
122
- {
123
- // Check this is a Basic Auth header
124
- if (
125
- authHeader == null ||
126
- authHeader.Length == 0 ||
127
- !authHeader.StartsWith("Basic")
128
- ) return null;
129
-
130
- // Pull out the Credentials with are seperated by ':' and Base64 encoded
131
- // Won't handle password with : in it, but that's OK for these tests
132
- string base64Credentials = authHeader.Substring(6);
133
- string[] credentials = Encoding.ASCII.GetString(
134
- Convert.FromBase64String(base64Credentials)
135
- ).Split(new char[] { ':' });
136
-
137
- if (credentials.Length != 2 ||
138
- string.IsNullOrEmpty(credentials[0]) ||
139
- string.IsNullOrEmpty(credentials[0])
140
- ) return null;
141
-
142
- return credentials;
143
- }
144
-
145
- } // class CustomBasicAuthenticationProvider
@@ -1,578 +0,0 @@
1
- //------------------------------------------------------------------------------
2
- // <auto-generated>
3
- // This code was generated from a template.
4
- //
5
- // Manual changes to this file may cause unexpected behavior in your application.
6
- // Manual changes to this file will be overwritten if the code is regenerated.
7
- // </auto-generated>
8
- //------------------------------------------------------------------------------
9
-
10
- using System;
11
- using System.Data.Objects;
12
- using System.Data.Objects.DataClasses;
13
- using System.Data.EntityClient;
14
- using System.ComponentModel;
15
- using System.Xml.Serialization;
16
- using System.Runtime.Serialization;
17
-
18
- [assembly: EdmSchemaAttribute()]
19
- #region EDM Relationship Metadata
20
-
21
- [assembly: EdmRelationshipAttribute("Model", "CategoryProduct", "Category", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(Model.Category), "Product", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(Model.Product))]
22
-
23
- #endregion
24
-
25
- namespace Model
26
- {
27
- #region Contexts
28
-
29
- /// <summary>
30
- /// No Metadata Documentation available.
31
- /// </summary>
32
- public partial class ModelContainer : ObjectContext
33
- {
34
- #region Constructors
35
-
36
- /// <summary>
37
- /// Initializes a new ModelContainer object using the connection string found in the 'ModelContainer' section of the application configuration file.
38
- /// </summary>
39
- public ModelContainer() : base("name=ModelContainer", "ModelContainer")
40
- {
41
- this.ContextOptions.LazyLoadingEnabled = true;
42
- OnContextCreated();
43
- }
44
-
45
- /// <summary>
46
- /// Initialize a new ModelContainer object.
47
- /// </summary>
48
- public ModelContainer(string connectionString) : base(connectionString, "ModelContainer")
49
- {
50
- this.ContextOptions.LazyLoadingEnabled = true;
51
- OnContextCreated();
52
- }
53
-
54
- /// <summary>
55
- /// Initialize a new ModelContainer object.
56
- /// </summary>
57
- public ModelContainer(EntityConnection connection) : base(connection, "ModelContainer")
58
- {
59
- this.ContextOptions.LazyLoadingEnabled = true;
60
- OnContextCreated();
61
- }
62
-
63
- #endregion
64
-
65
- #region Partial Methods
66
-
67
- partial void OnContextCreated();
68
-
69
- #endregion
70
-
71
- #region ObjectSet Properties
72
-
73
- /// <summary>
74
- /// No Metadata Documentation available.
75
- /// </summary>
76
- public ObjectSet<Product> Products
77
- {
78
- get
79
- {
80
- if ((_Products == null))
81
- {
82
- _Products = base.CreateObjectSet<Product>("Products");
83
- }
84
- return _Products;
85
- }
86
- }
87
- private ObjectSet<Product> _Products;
88
-
89
- /// <summary>
90
- /// No Metadata Documentation available.
91
- /// </summary>
92
- public ObjectSet<Category> Categories
93
- {
94
- get
95
- {
96
- if ((_Categories == null))
97
- {
98
- _Categories = base.CreateObjectSet<Category>("Categories");
99
- }
100
- return _Categories;
101
- }
102
- }
103
- private ObjectSet<Category> _Categories;
104
-
105
- #endregion
106
- #region AddTo Methods
107
-
108
- /// <summary>
109
- /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
110
- /// </summary>
111
- public void AddToProducts(Product product)
112
- {
113
- base.AddObject("Products", product);
114
- }
115
-
116
- /// <summary>
117
- /// Deprecated Method for adding a new object to the Categories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
118
- /// </summary>
119
- public void AddToCategories(Category category)
120
- {
121
- base.AddObject("Categories", category);
122
- }
123
-
124
- #endregion
125
- }
126
-
127
-
128
- #endregion
129
-
130
- #region Entities
131
-
132
- /// <summary>
133
- /// No Metadata Documentation available.
134
- /// </summary>
135
- [EdmEntityTypeAttribute(NamespaceName="Model", Name="Category")]
136
- [Serializable()]
137
- [DataContractAttribute(IsReference=true)]
138
- public partial class Category : EntityObject
139
- {
140
- #region Factory Method
141
-
142
- /// <summary>
143
- /// Create a new Category object.
144
- /// </summary>
145
- /// <param name="id">Initial value of the Id property.</param>
146
- /// <param name="name">Initial value of the Name property.</param>
147
- public static Category CreateCategory(global::System.Int32 id, global::System.String name)
148
- {
149
- Category category = new Category();
150
- category.Id = id;
151
- category.Name = name;
152
- return category;
153
- }
154
-
155
- #endregion
156
- #region Primitive Properties
157
-
158
- /// <summary>
159
- /// No Metadata Documentation available.
160
- /// </summary>
161
- [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
162
- [DataMemberAttribute()]
163
- public global::System.Int32 Id
164
- {
165
- get
166
- {
167
- return _Id;
168
- }
169
- set
170
- {
171
- if (_Id != value)
172
- {
173
- OnIdChanging(value);
174
- ReportPropertyChanging("Id");
175
- _Id = StructuralObject.SetValidValue(value);
176
- ReportPropertyChanged("Id");
177
- OnIdChanged();
178
- }
179
- }
180
- }
181
- private global::System.Int32 _Id;
182
- partial void OnIdChanging(global::System.Int32 value);
183
- partial void OnIdChanged();
184
-
185
- /// <summary>
186
- /// No Metadata Documentation available.
187
- /// </summary>
188
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
189
- [DataMemberAttribute()]
190
- public global::System.String Name
191
- {
192
- get
193
- {
194
- return _Name;
195
- }
196
- set
197
- {
198
- OnNameChanging(value);
199
- ReportPropertyChanging("Name");
200
- _Name = StructuralObject.SetValidValue(value, false);
201
- ReportPropertyChanged("Name");
202
- OnNameChanged();
203
- }
204
- }
205
- private global::System.String _Name;
206
- partial void OnNameChanging(global::System.String value);
207
- partial void OnNameChanged();
208
-
209
- #endregion
210
-
211
- #region Navigation Properties
212
-
213
- /// <summary>
214
- /// No Metadata Documentation available.
215
- /// </summary>
216
- [XmlIgnoreAttribute()]
217
- [SoapIgnoreAttribute()]
218
- [DataMemberAttribute()]
219
- [EdmRelationshipNavigationPropertyAttribute("Model", "CategoryProduct", "Product")]
220
- public EntityCollection<Product> Products
221
- {
222
- get
223
- {
224
- return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Product>("Model.CategoryProduct", "Product");
225
- }
226
- set
227
- {
228
- if ((value != null))
229
- {
230
- ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Product>("Model.CategoryProduct", "Product", value);
231
- }
232
- }
233
- }
234
-
235
- #endregion
236
- }
237
-
238
- /// <summary>
239
- /// No Metadata Documentation available.
240
- /// </summary>
241
- [EdmEntityTypeAttribute(NamespaceName="Model", Name="Product")]
242
- [Serializable()]
243
- [DataContractAttribute(IsReference=true)]
244
- public partial class Product : EntityObject
245
- {
246
- #region Factory Method
247
-
248
- /// <summary>
249
- /// Create a new Product object.
250
- /// </summary>
251
- /// <param name="id">Initial value of the Id property.</param>
252
- /// <param name="name">Initial value of the Name property.</param>
253
- /// <param name="description">Initial value of the Description property.</param>
254
- /// <param name="price">Initial value of the Price property.</param>
255
- /// <param name="auditFields">Initial value of the AuditFields property.</param>
256
- public static Product CreateProduct(global::System.Int32 id, global::System.String name, global::System.String description, global::System.Decimal price, AuditFields auditFields)
257
- {
258
- Product product = new Product();
259
- product.Id = id;
260
- product.Name = name;
261
- product.Description = description;
262
- product.Price = price;
263
- product.AuditFields = StructuralObject.VerifyComplexObjectIsNotNull(auditFields, "AuditFields");
264
- return product;
265
- }
266
-
267
- #endregion
268
- #region Primitive Properties
269
-
270
- /// <summary>
271
- /// No Metadata Documentation available.
272
- /// </summary>
273
- [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
274
- [DataMemberAttribute()]
275
- public global::System.Int32 Id
276
- {
277
- get
278
- {
279
- return _Id;
280
- }
281
- set
282
- {
283
- if (_Id != value)
284
- {
285
- OnIdChanging(value);
286
- ReportPropertyChanging("Id");
287
- _Id = StructuralObject.SetValidValue(value);
288
- ReportPropertyChanged("Id");
289
- OnIdChanged();
290
- }
291
- }
292
- }
293
- private global::System.Int32 _Id;
294
- partial void OnIdChanging(global::System.Int32 value);
295
- partial void OnIdChanged();
296
-
297
- /// <summary>
298
- /// No Metadata Documentation available.
299
- /// </summary>
300
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
301
- [DataMemberAttribute()]
302
- public global::System.String Name
303
- {
304
- get
305
- {
306
- return _Name;
307
- }
308
- set
309
- {
310
- OnNameChanging(value);
311
- ReportPropertyChanging("Name");
312
- _Name = StructuralObject.SetValidValue(value, false);
313
- ReportPropertyChanged("Name");
314
- OnNameChanged();
315
- }
316
- }
317
- private global::System.String _Name;
318
- partial void OnNameChanging(global::System.String value);
319
- partial void OnNameChanged();
320
-
321
- /// <summary>
322
- /// No Metadata Documentation available.
323
- /// </summary>
324
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
325
- [DataMemberAttribute()]
326
- public global::System.String Description
327
- {
328
- get
329
- {
330
- return _Description;
331
- }
332
- set
333
- {
334
- OnDescriptionChanging(value);
335
- ReportPropertyChanging("Description");
336
- _Description = StructuralObject.SetValidValue(value, false);
337
- ReportPropertyChanged("Description");
338
- OnDescriptionChanged();
339
- }
340
- }
341
- private global::System.String _Description;
342
- partial void OnDescriptionChanging(global::System.String value);
343
- partial void OnDescriptionChanged();
344
-
345
- /// <summary>
346
- /// No Metadata Documentation available.
347
- /// </summary>
348
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
349
- [DataMemberAttribute()]
350
- public global::System.Decimal Price
351
- {
352
- get
353
- {
354
- return _Price;
355
- }
356
- set
357
- {
358
- OnPriceChanging(value);
359
- ReportPropertyChanging("Price");
360
- _Price = StructuralObject.SetValidValue(value);
361
- ReportPropertyChanged("Price");
362
- OnPriceChanged();
363
- }
364
- }
365
- private global::System.Decimal _Price;
366
- partial void OnPriceChanging(global::System.Decimal value);
367
- partial void OnPriceChanged();
368
-
369
- /// <summary>
370
- /// No Metadata Documentation available.
371
- /// </summary>
372
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
373
- [DataMemberAttribute()]
374
- public Nullable<global::System.DateTime> DiscontinuedDate
375
- {
376
- get
377
- {
378
- return _DiscontinuedDate;
379
- }
380
- set
381
- {
382
- OnDiscontinuedDateChanging(value);
383
- ReportPropertyChanging("DiscontinuedDate");
384
- _DiscontinuedDate = StructuralObject.SetValidValue(value);
385
- ReportPropertyChanged("DiscontinuedDate");
386
- OnDiscontinuedDateChanged();
387
- }
388
- }
389
- private Nullable<global::System.DateTime> _DiscontinuedDate;
390
- partial void OnDiscontinuedDateChanging(Nullable<global::System.DateTime> value);
391
- partial void OnDiscontinuedDateChanged();
392
-
393
- #endregion
394
- #region Complex Properties
395
-
396
- /// <summary>
397
- /// No Metadata Documentation available.
398
- /// </summary>
399
- [EdmComplexPropertyAttribute()]
400
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
401
- [XmlElement(IsNullable=true)]
402
- [SoapElement(IsNullable=true)]
403
- [DataMemberAttribute()]
404
- public AuditFields AuditFields
405
- {
406
- get
407
- {
408
- _AuditFields = GetValidValue(_AuditFields, "AuditFields", false, _AuditFieldsInitialized);
409
- _AuditFieldsInitialized = true;
410
- return _AuditFields;
411
- }
412
- set
413
- {
414
- OnAuditFieldsChanging(value);
415
- ReportPropertyChanging("AuditFields");
416
- _AuditFields = SetValidValue(_AuditFields, value, "AuditFields");
417
- _AuditFieldsInitialized = true;
418
- ReportPropertyChanged("AuditFields");
419
- OnAuditFieldsChanged();
420
- }
421
- }
422
- private AuditFields _AuditFields;
423
- private bool _AuditFieldsInitialized;
424
- partial void OnAuditFieldsChanging(AuditFields value);
425
- partial void OnAuditFieldsChanged();
426
-
427
- #endregion
428
-
429
- #region Navigation Properties
430
-
431
- /// <summary>
432
- /// No Metadata Documentation available.
433
- /// </summary>
434
- [XmlIgnoreAttribute()]
435
- [SoapIgnoreAttribute()]
436
- [DataMemberAttribute()]
437
- [EdmRelationshipNavigationPropertyAttribute("Model", "CategoryProduct", "Category")]
438
- public Category Category
439
- {
440
- get
441
- {
442
- return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Category>("Model.CategoryProduct", "Category").Value;
443
- }
444
- set
445
- {
446
- ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Category>("Model.CategoryProduct", "Category").Value = value;
447
- }
448
- }
449
- /// <summary>
450
- /// No Metadata Documentation available.
451
- /// </summary>
452
- [BrowsableAttribute(false)]
453
- [DataMemberAttribute()]
454
- public EntityReference<Category> CategoryReference
455
- {
456
- get
457
- {
458
- return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Category>("Model.CategoryProduct", "Category");
459
- }
460
- set
461
- {
462
- if ((value != null))
463
- {
464
- ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Category>("Model.CategoryProduct", "Category", value);
465
- }
466
- }
467
- }
468
-
469
- #endregion
470
- }
471
-
472
- #endregion
473
- #region ComplexTypes
474
-
475
- /// <summary>
476
- /// No Metadata Documentation available.
477
- /// </summary>
478
- [EdmComplexTypeAttribute(NamespaceName="Model", Name="AuditFields")]
479
- [DataContractAttribute(IsReference=true)]
480
- [Serializable()]
481
- public partial class AuditFields : ComplexObject
482
- {
483
- #region Factory Method
484
-
485
- /// <summary>
486
- /// Create a new AuditFields object.
487
- /// </summary>
488
- /// <param name="createDate">Initial value of the CreateDate property.</param>
489
- /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
490
- public static AuditFields CreateAuditFields(global::System.DateTime createDate, global::System.DateTime modifiedDate)
491
- {
492
- AuditFields auditFields = new AuditFields();
493
- auditFields.CreateDate = createDate;
494
- auditFields.ModifiedDate = modifiedDate;
495
- return auditFields;
496
- }
497
-
498
- #endregion
499
- #region Primitive Properties
500
-
501
- /// <summary>
502
- /// No Metadata Documentation available.
503
- /// </summary>
504
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
505
- [DataMemberAttribute()]
506
- public global::System.DateTime CreateDate
507
- {
508
- get
509
- {
510
- return _CreateDate;
511
- }
512
- set
513
- {
514
- OnCreateDateChanging(value);
515
- ReportPropertyChanging("CreateDate");
516
- _CreateDate = StructuralObject.SetValidValue(value);
517
- ReportPropertyChanged("CreateDate");
518
- OnCreateDateChanged();
519
- }
520
- }
521
- private global::System.DateTime _CreateDate;
522
- partial void OnCreateDateChanging(global::System.DateTime value);
523
- partial void OnCreateDateChanged();
524
-
525
- /// <summary>
526
- /// No Metadata Documentation available.
527
- /// </summary>
528
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
529
- [DataMemberAttribute()]
530
- public global::System.DateTime ModifiedDate
531
- {
532
- get
533
- {
534
- return _ModifiedDate;
535
- }
536
- set
537
- {
538
- OnModifiedDateChanging(value);
539
- ReportPropertyChanging("ModifiedDate");
540
- _ModifiedDate = StructuralObject.SetValidValue(value);
541
- ReportPropertyChanged("ModifiedDate");
542
- OnModifiedDateChanged();
543
- }
544
- }
545
- private global::System.DateTime _ModifiedDate;
546
- partial void OnModifiedDateChanging(global::System.DateTime value);
547
- partial void OnModifiedDateChanged();
548
-
549
- /// <summary>
550
- /// No Metadata Documentation available.
551
- /// </summary>
552
- [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
553
- [DataMemberAttribute()]
554
- public global::System.String CreatedBy
555
- {
556
- get
557
- {
558
- return _CreatedBy;
559
- }
560
- set
561
- {
562
- OnCreatedByChanging(value);
563
- ReportPropertyChanging("CreatedBy");
564
- _CreatedBy = StructuralObject.SetValidValue(value, true);
565
- ReportPropertyChanged("CreatedBy");
566
- OnCreatedByChanged();
567
- }
568
- }
569
- private global::System.String _CreatedBy;
570
- partial void OnCreatedByChanging(global::System.String value);
571
- partial void OnCreatedByChanged();
572
-
573
- #endregion
574
- }
575
-
576
- #endregion
577
-
578
- }