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.
- data/.gitignore +9 -3
- data/.travis.yml +4 -0
- data/CHANGELOG.rdoc +18 -1
- data/README.rdoc +77 -19
- data/config/cucumber.yml +4 -3
- data/features/basic_auth.feature +5 -7
- data/features/batch_request.feature +11 -11
- data/features/complex_types.feature +11 -11
- data/features/query_builder.feature +27 -18
- data/features/service.feature +8 -8
- data/features/service_manage.feature +27 -12
- data/features/service_methods.feature +37 -0
- data/features/ssl.feature +4 -4
- data/features/step_definitions/pickle_steps.rb +100 -0
- data/features/step_definitions/service_steps.rb +99 -65
- data/features/support/constants.rb +3 -0
- data/features/support/custom_helpers.rb +54 -0
- data/features/support/env.rb +0 -10
- data/features/support/hooks.rb +1 -1
- data/features/support/pickle.rb +82 -0
- data/features/type_conversion.feature +10 -10
- data/lib/ruby_odata.rb +4 -1
- data/lib/ruby_odata/association.rb +36 -0
- data/lib/ruby_odata/class_builder.rb +96 -16
- data/lib/ruby_odata/helpers.rb +10 -0
- data/lib/ruby_odata/operation.rb +7 -5
- data/lib/ruby_odata/property_metadata.rb +11 -6
- data/lib/ruby_odata/query_builder.rb +20 -1
- data/lib/ruby_odata/service.rb +407 -94
- data/lib/ruby_odata/version.rb +1 -1
- data/ruby_odata.gemspec +2 -0
- data/spec/association_spec.rb +48 -0
- data/spec/class_builder_spec.rb +11 -2
- data/spec/fixtures/inheritance/edmx_pluralsight.xml +111 -0
- data/spec/fixtures/inheritance/result_pluralsight_courses.xml +229 -0
- data/spec/fixtures/links/result_links_query.xml +6 -0
- data/spec/fixtures/partial/partial_feed_metadata.xml +25 -0
- data/spec/fixtures/partial/partial_feed_part_1.xml +42 -0
- data/spec/fixtures/partial/partial_feed_part_2.xml +42 -0
- data/spec/fixtures/partial/partial_feed_part_3.xml +40 -0
- data/spec/fixtures/sample_service/edmx_categories_products.xml +1 -0
- data/spec/fixtures/sample_service/result_category_names.xml +5 -0
- data/spec/fixtures/sample_service/result_entity_category_web_get.xml +29 -0
- data/spec/fixtures/sample_service/result_entity_single_category_web_get.xml +23 -0
- data/spec/fixtures/sample_service/result_first_category_id.xml +2 -0
- data/spec/fixtures/sample_service/result_multiple_category_products.xml +57 -0
- data/spec/fixtures/sample_service/result_single_category.xml +18 -0
- data/spec/fixtures/sample_service/result_single_product.xml +26 -0
- data/spec/fixtures/sample_service/result_single_product_not_found.xml +4 -0
- data/spec/fixtures/sap/edmx_sap_demo_flight.xml +62 -58
- data/spec/property_metadata_spec.rb +9 -2
- data/spec/query_builder_spec.rb +11 -0
- data/spec/revised_service_spec.rb +197 -0
- data/spec/service_spec.rb +463 -4
- data/test/RubyODataService/RubyODataService.sln +20 -0
- data/test/RubyODataService/RubyODataService/App_Start/EntityFramework.SqlServerCompact.cs +12 -0
- data/test/RubyODataService/RubyODataService/BasicAuth/RubyOData.svc +3 -0
- data/test/RubyODataService/RubyODataService/BasicAuth/RubyOData.svc.cs +107 -0
- data/test/RubyODataService/RubyODataService/Global.asax +1 -0
- data/test/RubyODataService/RubyODataService/Global.asax.cs +49 -0
- data/test/RubyODataService/RubyODataService/Models/AuditFields.cs +16 -0
- data/test/RubyODataService/RubyODataService/Models/Category.cs +16 -0
- data/test/RubyODataService/RubyODataService/Models/Product.cs +20 -0
- data/test/RubyODataService/RubyODataService/Properties/AssemblyInfo.cs +35 -0
- data/test/RubyODataService/RubyODataService/RubyOData.svc +3 -0
- data/test/RubyODataService/RubyODataService/RubyOData.svc.cs +57 -0
- data/test/RubyODataService/RubyODataService/RubyODataContext.cs +16 -0
- data/test/RubyODataService/RubyODataService/RubyODataService.csproj +159 -0
- data/test/RubyODataService/RubyODataService/RubyODataService.csproj.user +31 -0
- data/test/RubyODataService/RubyODataService/Web.Debug.config +30 -0
- data/test/RubyODataService/RubyODataService/Web.Release.config +31 -0
- data/test/RubyODataService/RubyODataService/Web.config +27 -0
- data/test/RubyODataService/RubyODataService/bin/EntityFramework.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Edm.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.OData.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Services.Client.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Services.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Spatial.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/RubyODataService.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/System.Data.SqlServerCe.Entity.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/System.Data.SqlServerCe.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/System.Spatial.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/WebActivator.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/README_ENU.txt +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/msvcr90.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/sqlcecompact40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/sqlceer40EN.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/sqlceme40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/sqlceqp40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/amd64/sqlcese40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
- data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/README_ENU.txt +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/msvcr90.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/sqlcecompact40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/sqlceer40EN.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/sqlceme40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/sqlceqp40.dll +0 -0
- data/test/RubyODataService/RubyODataService/bin/x86/sqlcese40.dll +0 -0
- data/test/RubyODataService/RubyODataService/packages.config +7 -0
- data/test/RubyODataService/packages/EntityFramework.4.2.0.0/EntityFramework.4.2.0.0.nupkg +0 -0
- data/test/RubyODataService/packages/EntityFramework.4.2.0.0/lib/net40/EntityFramework.dll +0 -0
- data/test/RubyODataService/packages/EntityFramework.4.2.0.0/lib/net40/EntityFramework.xml +13488 -0
- data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/Content/App_Start/EntityFramework.SqlServerCompact.cs.pp +12 -0
- data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/EULA_ENU.rtf +969 -0
- data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/EntityFramework.SqlServerCompact.4.1.8482.2.nupkg +0 -0
- data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/lib/System.Data.SqlServerCe.Entity.dll +0 -0
- data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/tools/install.ps1 +3 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Content/web.config.transform +8 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/README_ENU.txt +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/msvcr90.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlcecompact40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceer40EN.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceme40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceqp40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlcese40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/README_ENU.txt +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/msvcr90.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlcecompact40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceer40EN.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceme40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceqp40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlcese40.dll +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/SQLCE_EULA_ENU.rtf +778 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/SqlServerCompact.4.0.8482.1.nupkg +0 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/GetSqlCEPostBuildCmd.ps1 +12 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/install.ps1 +11 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/uninstall.ps1 +9 -0
- data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/lib/System.Data.SqlServerCe.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/DataSvcUtil.exe +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/License.rtf +708 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Edm.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Edm.xml +4150 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.OData.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.OData.xml +1969 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Client.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Client.xml +1442 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Design.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Design.xml +191 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.xml +2559 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Spatial.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Spatial.xml +15 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.VsDesigner.DataServices.Adapter.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/README.txt +6 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/System.Spatial.dll +0 -0
- data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/System.Spatial.xml +2276 -0
- data/test/RubyODataService/packages/WebActivator.1.0.0.0/WebActivator.1.0.0.0.nupkg +0 -0
- data/test/RubyODataService/packages/WebActivator.1.0.0.0/lib/WebActivator.dll +0 -0
- data/test/RubyODataService/packages/repositories.config +4 -0
- data/test/applicationhost.config.template +2 -2
- data/test/blueprints.rb +5 -4
- data/test/iisExpress x64.bat b/data/test/iisExpress → x64.bat +0 -0
- data/test/iisExpress x86.bat b/data/test/iisExpress → x86.bat +0 -0
- data/test/setpath.rb +13 -3
- data/test/usage_samples/querying.rb +45 -0
- data/test/usage_samples/reflection.rb +16 -0
- data/test/usage_samples/sample_data.rb +30 -0
- metadata +327 -36
- data/test/Cassini x64.bat +0 -1
- data/test/Cassini x86.bat +0 -1
- data/test/SampleService/App_Code/AuditFields.cs +0 -13
- data/test/SampleService/App_Code/Entities.cs +0 -145
- data/test/SampleService/App_Code/Model.Designer.cs +0 -578
- data/test/SampleService/App_Code/Model.edmx +0 -157
- data/test/SampleService/App_Code/ModelContainerExtended.cs +0 -32
- data/test/SampleService/App_Data/_TestDB.mdf +0 -0
- data/test/SampleService/App_Data/_TestDB_Log.ldf +0 -0
- data/test/SampleService/BasicAuth/Entities.svc +0 -1
- data/test/SampleService/Entities.svc +0 -1
- data/test/SampleService/web.config +0 -37
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
Microsoft Visual Studio Solution File, Format Version 11.00
|
3
|
+
# Visual Studio 2010
|
4
|
+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyODataService", "RubyODataService\RubyODataService.csproj", "{C84F8120-25A8-4874-BAC2-9A19E114CFB2}"
|
5
|
+
EndProject
|
6
|
+
Global
|
7
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
8
|
+
Debug|Any CPU = Debug|Any CPU
|
9
|
+
Release|Any CPU = Release|Any CPU
|
10
|
+
EndGlobalSection
|
11
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
12
|
+
{C84F8120-25A8-4874-BAC2-9A19E114CFB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
13
|
+
{C84F8120-25A8-4874-BAC2-9A19E114CFB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
14
|
+
{C84F8120-25A8-4874-BAC2-9A19E114CFB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
15
|
+
{C84F8120-25A8-4874-BAC2-9A19E114CFB2}.Release|Any CPU.Build.0 = Release|Any CPU
|
16
|
+
EndGlobalSection
|
17
|
+
GlobalSection(SolutionProperties) = preSolution
|
18
|
+
HideSolutionNode = FALSE
|
19
|
+
EndGlobalSection
|
20
|
+
EndGlobal
|
@@ -0,0 +1,12 @@
|
|
1
|
+
using System.Data.Entity;
|
2
|
+
using System.Data.Entity.Infrastructure;
|
3
|
+
|
4
|
+
[assembly: WebActivator.PreApplicationStartMethod(typeof(RubyODataService.App_Start.EntityFramework_SqlServerCompact), "Start")]
|
5
|
+
|
6
|
+
namespace RubyODataService.App_Start {
|
7
|
+
public static class EntityFramework_SqlServerCompact {
|
8
|
+
public static void Start() {
|
9
|
+
Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
using System;
|
2
|
+
using System.Linq;
|
3
|
+
using System.Security.Principal;
|
4
|
+
using System.Text;
|
5
|
+
using System.Web;
|
6
|
+
|
7
|
+
// ReSharper disable CheckNamespace
|
8
|
+
namespace RubyODataService
|
9
|
+
// ReSharper restore CheckNamespace
|
10
|
+
{
|
11
|
+
public class OurBasicAuthenticationModule : IHttpModule
|
12
|
+
{
|
13
|
+
public void Init(HttpApplication context)
|
14
|
+
{
|
15
|
+
context.AuthenticateRequest += context_AuthenticateRequest;
|
16
|
+
}
|
17
|
+
|
18
|
+
private void context_AuthenticateRequest(object sender, EventArgs e)
|
19
|
+
{
|
20
|
+
HttpApplication application = (HttpApplication)sender;
|
21
|
+
|
22
|
+
// Only require authentication if BasicAuth is in the URI path
|
23
|
+
if ((application.Context.Request.Url.AbsoluteUri.Contains("BasicAuth")) &&
|
24
|
+
(!CustomBasicAuthenticationProvider.Authenticate(application.Context)))
|
25
|
+
{
|
26
|
+
application.Context.Response.Status = "401 Unauthorized";
|
27
|
+
application.Context.Response.StatusCode = 401;
|
28
|
+
application.Context.Response.AddHeader("WWW-Authenticate", "Basic");
|
29
|
+
application.CompleteRequest();
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
public void Dispose()
|
34
|
+
{
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
// class OurBasicAuthenticationModule: IHttpModule
|
40
|
+
|
41
|
+
public class CustomBasicAuthenticationProvider
|
42
|
+
{
|
43
|
+
public static bool Authenticate(HttpContext context)
|
44
|
+
{
|
45
|
+
if (!HttpContext.Current.Request.Headers.AllKeys.Contains("Authorization"))
|
46
|
+
return false;
|
47
|
+
|
48
|
+
string authHeader = HttpContext.Current.Request.Headers["Authorization"];
|
49
|
+
|
50
|
+
IPrincipal principal;
|
51
|
+
if (TryGetPrincipal(authHeader, out principal))
|
52
|
+
{
|
53
|
+
HttpContext.Current.User = principal;
|
54
|
+
return true;
|
55
|
+
}
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
|
59
|
+
private static bool TryGetPrincipal(string authHeader, out IPrincipal principal)
|
60
|
+
{
|
61
|
+
var creds = ParseAuthHeader(authHeader);
|
62
|
+
if (creds != null && TryGetPrincipal(creds, out principal))
|
63
|
+
return true;
|
64
|
+
|
65
|
+
principal = null;
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
|
69
|
+
private static bool TryGetPrincipal(string[] creds, out IPrincipal principal)
|
70
|
+
{
|
71
|
+
if (creds[0] == "admin" && creds[1] == "passwd")
|
72
|
+
{
|
73
|
+
principal = new GenericPrincipal(
|
74
|
+
new GenericIdentity("Administrator"),
|
75
|
+
new[] { "Administrator", "User" }
|
76
|
+
);
|
77
|
+
return true;
|
78
|
+
}
|
79
|
+
principal = null;
|
80
|
+
return false;
|
81
|
+
}
|
82
|
+
|
83
|
+
private static string[] ParseAuthHeader(string authHeader)
|
84
|
+
{
|
85
|
+
// Check this is a Basic Auth header
|
86
|
+
if (
|
87
|
+
string.IsNullOrEmpty(authHeader) ||
|
88
|
+
!authHeader.StartsWith("Basic")
|
89
|
+
) return null;
|
90
|
+
|
91
|
+
// Pull out the Credentials with are seperated by ':' and Base64 encoded
|
92
|
+
// Won't handle password with : in it, but that's OK for these tests
|
93
|
+
var base64Credentials = authHeader.Substring(6);
|
94
|
+
var credentials = Encoding.ASCII.GetString(Convert.FromBase64String(base64Credentials)).Split(new[] { ':' });
|
95
|
+
|
96
|
+
if (credentials.Length != 2 ||
|
97
|
+
string.IsNullOrEmpty(credentials[0]) ||
|
98
|
+
string.IsNullOrEmpty(credentials[0])
|
99
|
+
) return null;
|
100
|
+
|
101
|
+
return credentials;
|
102
|
+
}
|
103
|
+
|
104
|
+
}
|
105
|
+
|
106
|
+
// class CustomBasicAuthenticationProvider
|
107
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<%@ Application Codebehind="Global.asax.cs" Inherits="RubyODataService.Global" Language="C#" %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
using System;
|
2
|
+
using System.Collections.Generic;
|
3
|
+
using System.Data.Entity;
|
4
|
+
using System.Linq;
|
5
|
+
using System.Web;
|
6
|
+
using System.Web.Security;
|
7
|
+
using System.Web.SessionState;
|
8
|
+
|
9
|
+
namespace RubyODataService
|
10
|
+
{
|
11
|
+
public class Global : System.Web.HttpApplication
|
12
|
+
{
|
13
|
+
|
14
|
+
protected void Application_Start(object sender, EventArgs e)
|
15
|
+
{
|
16
|
+
Database.SetInitializer(new DropCreateDatabaseAlways<RubyODataContext>());
|
17
|
+
}
|
18
|
+
|
19
|
+
protected void Session_Start(object sender, EventArgs e)
|
20
|
+
{
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
protected void Application_BeginRequest(object sender, EventArgs e)
|
25
|
+
{
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
protected void Application_AuthenticateRequest(object sender, EventArgs e)
|
30
|
+
{
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
protected void Application_Error(object sender, EventArgs e)
|
35
|
+
{
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
protected void Session_End(object sender, EventArgs e)
|
40
|
+
{
|
41
|
+
|
42
|
+
}
|
43
|
+
|
44
|
+
protected void Application_End(object sender, EventArgs e)
|
45
|
+
{
|
46
|
+
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
using System;
|
2
|
+
|
3
|
+
namespace RubyODataService.Models
|
4
|
+
{
|
5
|
+
public class AuditFields
|
6
|
+
{
|
7
|
+
public AuditFields()
|
8
|
+
{
|
9
|
+
CreateDate = DateTime.UtcNow;
|
10
|
+
ModifiedDate = DateTime.UtcNow;
|
11
|
+
}
|
12
|
+
public DateTime CreateDate { get; set; }
|
13
|
+
public DateTime ModifiedDate { get; set; }
|
14
|
+
public string CreatedBy { get; set; }
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
using System.Collections.Generic;
|
2
|
+
|
3
|
+
namespace RubyODataService.Models
|
4
|
+
{
|
5
|
+
public class Category
|
6
|
+
{
|
7
|
+
public Category()
|
8
|
+
{
|
9
|
+
AuditFields = new AuditFields();
|
10
|
+
}
|
11
|
+
public int Id { get; set; }
|
12
|
+
public string Name { get; set; }
|
13
|
+
public virtual ICollection<Product> Products { get; set; }
|
14
|
+
public AuditFields AuditFields { get; set; }
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
using System;
|
2
|
+
|
3
|
+
namespace RubyODataService.Models
|
4
|
+
{
|
5
|
+
public class Product
|
6
|
+
{
|
7
|
+
public Product()
|
8
|
+
{
|
9
|
+
AuditFields = new AuditFields();
|
10
|
+
}
|
11
|
+
public int Id { get; set; }
|
12
|
+
public string Name { get; set; }
|
13
|
+
public string Description { get; set; }
|
14
|
+
public decimal Price { get; set; }
|
15
|
+
public DateTime? DiscontinuedDate { get; set; }
|
16
|
+
public int CategoryId { get; set; }
|
17
|
+
public Category Category { get; set; }
|
18
|
+
public AuditFields AuditFields { get; set; }
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
using System.Reflection;
|
2
|
+
using System.Runtime.CompilerServices;
|
3
|
+
using System.Runtime.InteropServices;
|
4
|
+
|
5
|
+
// General Information about an assembly is controlled through the following
|
6
|
+
// set of attributes. Change these attribute values to modify the information
|
7
|
+
// associated with an assembly.
|
8
|
+
[assembly: AssemblyTitle("RubyODataService")]
|
9
|
+
[assembly: AssemblyDescription("")]
|
10
|
+
[assembly: AssemblyConfiguration("")]
|
11
|
+
[assembly: AssemblyCompany("")]
|
12
|
+
[assembly: AssemblyProduct("RubyODataService")]
|
13
|
+
[assembly: AssemblyCopyright("Copyright © 2011")]
|
14
|
+
[assembly: AssemblyTrademark("")]
|
15
|
+
[assembly: AssemblyCulture("")]
|
16
|
+
|
17
|
+
// Setting ComVisible to false makes the types in this assembly not visible
|
18
|
+
// to COM components. If you need to access a type in this assembly from
|
19
|
+
// COM, set the ComVisible attribute to true on that type.
|
20
|
+
[assembly: ComVisible(false)]
|
21
|
+
|
22
|
+
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
23
|
+
[assembly: Guid("6fc9bddf-fa99-4dc4-a66f-b8f15d3efb00")]
|
24
|
+
|
25
|
+
// Version information for an assembly consists of the following four values:
|
26
|
+
//
|
27
|
+
// Major Version
|
28
|
+
// Minor Version
|
29
|
+
// Build Number
|
30
|
+
// Revision
|
31
|
+
//
|
32
|
+
// You can specify all the values or you can default the Revision and Build Numbers
|
33
|
+
// by using the '*' as shown below:
|
34
|
+
[assembly: AssemblyVersion("1.0.0.0")]
|
35
|
+
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -0,0 +1,57 @@
|
|
1
|
+
using System.Data.Services;
|
2
|
+
using System.Data.Services.Common;
|
3
|
+
using System.Linq;
|
4
|
+
using System.ServiceModel;
|
5
|
+
using System.ServiceModel.Web;
|
6
|
+
using RubyODataService.Models;
|
7
|
+
using System.Collections.Generic;
|
8
|
+
|
9
|
+
namespace RubyODataService
|
10
|
+
{
|
11
|
+
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
|
12
|
+
public class RubyOData : DataService<RubyODataContext>
|
13
|
+
{
|
14
|
+
// This method is called only once to initialize service-wide policies.
|
15
|
+
public static void InitializeService(DataServiceConfiguration config)
|
16
|
+
{
|
17
|
+
config.SetEntitySetAccessRule("*", EntitySetRights.All);
|
18
|
+
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
|
19
|
+
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
|
20
|
+
config.UseVerboseErrors = true;
|
21
|
+
}
|
22
|
+
|
23
|
+
/// <summary>
|
24
|
+
/// Cleans the database for testing.
|
25
|
+
/// </summary>
|
26
|
+
[WebInvoke]
|
27
|
+
public void CleanDatabaseForTesting()
|
28
|
+
{
|
29
|
+
CurrentDataSource.Database.Delete();
|
30
|
+
CurrentDataSource.Database.CreateIfNotExists();
|
31
|
+
}
|
32
|
+
|
33
|
+
[WebGet]
|
34
|
+
public IQueryable<Category> EntityCategoryWebGet()
|
35
|
+
{
|
36
|
+
return CurrentDataSource.Categories;
|
37
|
+
}
|
38
|
+
|
39
|
+
[WebGet]
|
40
|
+
public IQueryable<string> CategoryNames()
|
41
|
+
{
|
42
|
+
return CurrentDataSource.Categories.Select(c => c.Name);
|
43
|
+
}
|
44
|
+
|
45
|
+
[WebGet]
|
46
|
+
public int? FirstCategoryId()
|
47
|
+
{
|
48
|
+
return CurrentDataSource.Categories.Select(c => c.Id).FirstOrDefault();
|
49
|
+
}
|
50
|
+
|
51
|
+
[WebGet]
|
52
|
+
public Category EntitySingleCategoryWebGet(int id)
|
53
|
+
{
|
54
|
+
return CurrentDataSource.Categories.FirstOrDefault(c => c.Id == id);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
using System.Data.Entity;
|
2
|
+
using RubyODataService.Models;
|
3
|
+
|
4
|
+
namespace RubyODataService
|
5
|
+
{
|
6
|
+
public class RubyODataContext : DbContext
|
7
|
+
{
|
8
|
+
public RubyODataContext()
|
9
|
+
{
|
10
|
+
// Disable proxy creation, which doesn’t work well with data services.
|
11
|
+
this.Configuration.ProxyCreationEnabled = false;
|
12
|
+
}
|
13
|
+
public DbSet<Product> Products { get; set; }
|
14
|
+
public DbSet<Category> Categories { get; set; }
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,159 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3
|
+
<PropertyGroup>
|
4
|
+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
5
|
+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
6
|
+
<ProductVersion>
|
7
|
+
</ProductVersion>
|
8
|
+
<SchemaVersion>2.0</SchemaVersion>
|
9
|
+
<ProjectGuid>{C84F8120-25A8-4874-BAC2-9A19E114CFB2}</ProjectGuid>
|
10
|
+
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
11
|
+
<OutputType>Library</OutputType>
|
12
|
+
<AppDesignerFolder>Properties</AppDesignerFolder>
|
13
|
+
<RootNamespace>RubyODataService</RootNamespace>
|
14
|
+
<AssemblyName>RubyODataService</AssemblyName>
|
15
|
+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
16
|
+
<UseIISExpress>true</UseIISExpress>
|
17
|
+
</PropertyGroup>
|
18
|
+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
19
|
+
<DebugSymbols>true</DebugSymbols>
|
20
|
+
<DebugType>full</DebugType>
|
21
|
+
<Optimize>false</Optimize>
|
22
|
+
<OutputPath>bin\</OutputPath>
|
23
|
+
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
24
|
+
<ErrorReport>prompt</ErrorReport>
|
25
|
+
<WarningLevel>4</WarningLevel>
|
26
|
+
</PropertyGroup>
|
27
|
+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
28
|
+
<DebugType>pdbonly</DebugType>
|
29
|
+
<Optimize>true</Optimize>
|
30
|
+
<OutputPath>bin\</OutputPath>
|
31
|
+
<DefineConstants>TRACE</DefineConstants>
|
32
|
+
<ErrorReport>prompt</ErrorReport>
|
33
|
+
<WarningLevel>4</WarningLevel>
|
34
|
+
</PropertyGroup>
|
35
|
+
<ItemGroup>
|
36
|
+
<Reference Include="EntityFramework">
|
37
|
+
<HintPath>..\packages\EntityFramework.4.2.0.0\lib\net40\EntityFramework.dll</HintPath>
|
38
|
+
</Reference>
|
39
|
+
<Reference Include="Microsoft.CSharp" />
|
40
|
+
<Reference Include="Microsoft.Data.Edm, Version=4.99.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
41
|
+
<Private>True</Private>
|
42
|
+
</Reference>
|
43
|
+
<Reference Include="Microsoft.Data.OData, Version=4.99.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
44
|
+
<Private>True</Private>
|
45
|
+
</Reference>
|
46
|
+
<Reference Include="Microsoft.Data.Services, Version=4.99.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
47
|
+
<SpecificVersion>False</SpecificVersion>
|
48
|
+
<HintPath>C:\Program Files (x86)\Microsoft WCF Data Services October 2011 CTP\bin\.NETFramework\Microsoft.Data.Services.dll</HintPath>
|
49
|
+
<Private>True</Private>
|
50
|
+
</Reference>
|
51
|
+
<Reference Include="Microsoft.Data.Services.Client, Version=4.99.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
52
|
+
<SpecificVersion>False</SpecificVersion>
|
53
|
+
<HintPath>C:\Program Files (x86)\Microsoft WCF Data Services October 2011 CTP\bin\.NETFramework\Microsoft.Data.Services.Client.dll</HintPath>
|
54
|
+
<Private>True</Private>
|
55
|
+
</Reference>
|
56
|
+
<Reference Include="Microsoft.Data.Spatial, Version=4.99.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
57
|
+
<Reference Include="System.ComponentModel.DataAnnotations" />
|
58
|
+
<Reference Include="System.Data.Entity" />
|
59
|
+
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
60
|
+
<SpecificVersion>False</SpecificVersion>
|
61
|
+
<HintPath>..\packages\SqlServerCompact.4.0.8482.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
62
|
+
</Reference>
|
63
|
+
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
64
|
+
<SpecificVersion>False</SpecificVersion>
|
65
|
+
<HintPath>..\packages\EntityFramework.SqlServerCompact.4.1.8482.2\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
66
|
+
</Reference>
|
67
|
+
<Reference Include="System.ServiceModel" />
|
68
|
+
<Reference Include="System.ServiceModel.Web" />
|
69
|
+
<Reference Include="System.Spatial, Version=4.99.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
70
|
+
<Reference Include="System.Transactions" />
|
71
|
+
<Reference Include="System.Web.DynamicData" />
|
72
|
+
<Reference Include="System.Web.Entity" />
|
73
|
+
<Reference Include="System.Web.ApplicationServices" />
|
74
|
+
<Reference Include="System" />
|
75
|
+
<Reference Include="System.Data" />
|
76
|
+
<Reference Include="System.Core" />
|
77
|
+
<Reference Include="System.Data.DataSetExtensions" />
|
78
|
+
<Reference Include="System.Web.Extensions" />
|
79
|
+
<Reference Include="System.Xml.Linq" />
|
80
|
+
<Reference Include="System.Drawing" />
|
81
|
+
<Reference Include="System.Web" />
|
82
|
+
<Reference Include="System.Xml" />
|
83
|
+
<Reference Include="System.Configuration" />
|
84
|
+
<Reference Include="System.Web.Services" />
|
85
|
+
<Reference Include="System.EnterpriseServices" />
|
86
|
+
<Reference Include="WebActivator">
|
87
|
+
<HintPath>..\packages\WebActivator.1.0.0.0\lib\WebActivator.dll</HintPath>
|
88
|
+
</Reference>
|
89
|
+
</ItemGroup>
|
90
|
+
<ItemGroup>
|
91
|
+
<Content Include="BasicAuth\RubyOData.svc" />
|
92
|
+
<Content Include="Global.asax" />
|
93
|
+
<Content Include="RubyOData.svc" />
|
94
|
+
<Content Include="Web.config" />
|
95
|
+
<Content Include="Web.Debug.config">
|
96
|
+
<DependentUpon>Web.config</DependentUpon>
|
97
|
+
</Content>
|
98
|
+
<Content Include="Web.Release.config">
|
99
|
+
<DependentUpon>Web.config</DependentUpon>
|
100
|
+
</Content>
|
101
|
+
</ItemGroup>
|
102
|
+
<ItemGroup>
|
103
|
+
<Compile Include="App_Start\EntityFramework.SqlServerCompact.cs" />
|
104
|
+
<Compile Include="BasicAuth\RubyOData.svc.cs">
|
105
|
+
<DependentUpon>RubyOData.svc</DependentUpon>
|
106
|
+
</Compile>
|
107
|
+
<Compile Include="Global.asax.cs">
|
108
|
+
<DependentUpon>Global.asax</DependentUpon>
|
109
|
+
</Compile>
|
110
|
+
<Compile Include="Models\AuditFields.cs" />
|
111
|
+
<Compile Include="Models\Category.cs" />
|
112
|
+
<Compile Include="Models\Product.cs" />
|
113
|
+
<Compile Include="Properties\AssemblyInfo.cs" />
|
114
|
+
<Compile Include="RubyOData.svc.cs">
|
115
|
+
<DependentUpon>RubyOData.svc</DependentUpon>
|
116
|
+
</Compile>
|
117
|
+
<Compile Include="RubyODataContext.cs" />
|
118
|
+
</ItemGroup>
|
119
|
+
<ItemGroup>
|
120
|
+
<Content Include="packages.config" />
|
121
|
+
</ItemGroup>
|
122
|
+
<ItemGroup>
|
123
|
+
<Folder Include="App_Data\" />
|
124
|
+
</ItemGroup>
|
125
|
+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
126
|
+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
127
|
+
<ProjectExtensions>
|
128
|
+
<VisualStudio>
|
129
|
+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
130
|
+
<WebProjectProperties>
|
131
|
+
<UseIIS>True</UseIIS>
|
132
|
+
<AutoAssignPort>True</AutoAssignPort>
|
133
|
+
<DevelopmentServerPort>0</DevelopmentServerPort>
|
134
|
+
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
135
|
+
<IISUrl>http://localhost:6680/</IISUrl>
|
136
|
+
<NTLMAuthentication>False</NTLMAuthentication>
|
137
|
+
<UseCustomServer>False</UseCustomServer>
|
138
|
+
<CustomServerUrl>
|
139
|
+
</CustomServerUrl>
|
140
|
+
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
141
|
+
</WebProjectProperties>
|
142
|
+
</FlavorProperties>
|
143
|
+
</VisualStudio>
|
144
|
+
</ProjectExtensions>
|
145
|
+
<PropertyGroup>
|
146
|
+
<PostBuildEvent>
|
147
|
+
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
148
|
+
xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\x86\*.*" "$(TargetDir)x86"
|
149
|
+
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
|
150
|
+
xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
|
151
|
+
</PropertyGroup>
|
152
|
+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
153
|
+
Other similar extension points exist, see Microsoft.Common.targets.
|
154
|
+
<Target Name="BeforeBuild">
|
155
|
+
</Target>
|
156
|
+
<Target Name="AfterBuild">
|
157
|
+
</Target>
|
158
|
+
-->
|
159
|
+
</Project>
|