Permalink
Browse files

initial checkin.

  • Loading branch information...
0 parents commit 17e5f0a9c187af09f61854e5eb3bff4dcf4b8b1f @craiggwilson committed Aug 10, 2012
Showing with 1,443 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +60 −0 MongoDB.OData.sln
  3. +4 −0 README.md
  4. +136 −0 src/MongoDB.OData.SampleHost/MongoDB.OData.SampleHost.csproj
  5. +35 −0 src/MongoDB.OData.SampleHost/Properties/AssemblyInfo.cs
  6. +3 −0 src/MongoDB.OData.SampleHost/Sample.svc
  7. +105 −0 src/MongoDB.OData.SampleHost/Sample.svc.cs
  8. +30 −0 src/MongoDB.OData.SampleHost/Web.Debug.config
  9. +31 −0 src/MongoDB.OData.SampleHost/Web.Release.config
  10. +13 −0 src/MongoDB.OData.SampleHost/Web.config
  11. +9 −0 src/MongoDB.OData.SampleHost/packages.config
  12. +23 −0 src/MongoDB.OData.SampleModels/Blog.cs
  13. +18 −0 src/MongoDB.OData.SampleModels/BlogPostSummary.cs
  14. +16 −0 src/MongoDB.OData.SampleModels/Comment.cs
  15. +59 −0 src/MongoDB.OData.SampleModels/MongoDB.OData.SampleModels.csproj
  16. +29 −0 src/MongoDB.OData.SampleModels/Post.cs
  17. +36 −0 src/MongoDB.OData.SampleModels/Properties/AssemblyInfo.cs
  18. +20 −0 src/MongoDB.OData.SampleModels/User.cs
  19. +14 −0 src/MongoDB.OData.SampleModels/UserSummary.cs
  20. +87 −0 src/MongoDB.OData/MongoDB.OData.csproj
  21. +36 −0 src/MongoDB.OData/Properties/AssemblyInfo.cs
  22. +66 −0 src/MongoDB.OData/TypedMongoDataService.cs
  23. +230 −0 src/MongoDB.OData/TypedMongoDataServiceMetadata.cs
  24. +84 −0 src/MongoDB.OData/TypedMongoDataServiceMetadataProvider.cs
  25. +94 −0 src/MongoDB.OData/TypedMongoDataServiceQueryProvider.cs
  26. +24 −0 src/MongoDB.OData/TypedMongoResourcePropertyAnnotation.cs
  27. +30 −0 src/MongoDB.OData/TypedMongoResourceSetAnnotation.cs
  28. +53 −0 src/MongoDB.OData/TypedMongoResourceTypeAnnotation.cs
  29. +9 −0 src/MongoDB.OData/packages.config
  30. +6 −0 tools/NuGet/NuGet.Config
  31. BIN tools/NuGet/NuGet.exe
  32. +71 −0 tools/NuGet/NuGet.targets
@@ -0,0 +1,12 @@
+# Visual Studio
+bin
+obj
+*.user
+*.suo
+*.cache
+
+# Nuget
+packages
+
+# NCrunch
+*.ncrunch*
@@ -0,0 +1,60 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.OData", "src\MongoDB.OData\MongoDB.OData.csproj", "{FE1AD69A-98AB-4F2D-88C9-B7B449191912}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.OData.SampleHost", "src\MongoDB.OData.SampleHost\MongoDB.OData.SampleHost.csproj", "{D9B7A239-9F4E-4E55-838D-4766EBEA5672}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C6F8D4C8-3816-48F4-A278-88D6CF8776B7}"
+ ProjectSection(SolutionItems) = preProject
+ .gitignore = .gitignore
+ README.md = README.md
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.OData.SampleModels", "src\MongoDB.OData.SampleModels\MongoDB.OData.SampleModels.csproj", "{59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {FE1AD69A-98AB-4F2D-88C9-B7B449191912}.Release|x86.ActiveCfg = Release|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {D9B7A239-9F4E-4E55-838D-4766EBEA5672}.Release|x86.ActiveCfg = Release|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}.Release|x86.ActiveCfg = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,4 @@
+mongo-dotnet-odata
+==================
+
+An OData Provider for MongoDB
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>
+ </ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D9B7A239-9F4E-4E55-838D-4766EBEA5672}</ProjectGuid>
+ <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>MongoDB.OData.SampleHost</RootNamespace>
+ <AssemblyName>MongoDB.OData.SampleHost</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="Microsoft.Data.Edm">
+ <HintPath>..\packages\Microsoft.Data.Edm.5.0.0.50403\lib\net40\Microsoft.Data.Edm.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Data.OData">
+ <HintPath>..\packages\Microsoft.Data.OData.5.0.0.50403\lib\net40\Microsoft.Data.OData.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Data.Services">
+ <HintPath>..\packages\Microsoft.Data.Services.5.0.0.50403\lib\net40\Microsoft.Data.Services.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Data.Services.Client">
+ <HintPath>..\packages\Microsoft.Data.Services.Client.5.0.0.50403\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
+ </Reference>
+ <Reference Include="MongoDB.Bson">
+ <HintPath>..\packages\mongocsharpdriver.1.4.2\lib\net35\MongoDB.Bson.dll</HintPath>
+ </Reference>
+ <Reference Include="MongoDB.Driver">
+ <HintPath>..\packages\mongocsharpdriver.1.4.2\lib\net35\MongoDB.Driver.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data.Entity" />
+ <Reference Include="System.ServiceModel" />
+ <Reference Include="System.ServiceModel.Web" />
+ <Reference Include="System.Spatial">
+ <HintPath>..\packages\System.Spatial.5.0.0.50403\lib\net40\System.Spatial.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.DynamicData" />
+ <Reference Include="System.Web.Entity" />
+ <Reference Include="System.Web.ApplicationServices" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.EnterpriseServices" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Sample.svc" />
+ <Content Include="Web.config" />
+ <Content Include="Web.Debug.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </Content>
+ <Content Include="Web.Release.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Sample.svc.cs">
+ <DependentUpon>Sample.svc</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\MongoDB.OData.SampleModels\MongoDB.OData.SampleModels.csproj">
+ <Project>{59DA97A0-8CD9-461C-9EA5-1AE45D34A1A7}</Project>
+ <Name>MongoDB.OData.SampleModels</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\MongoDB.OData\MongoDB.OData.csproj">
+ <Project>{FE1AD69A-98AB-4F2D-88C9-B7B449191912}</Project>
+ <Name>MongoDB.OData</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
+ <WebProjectProperties>
+ <UseIIS>False</UseIIS>
+ <AutoAssignPort>True</AutoAssignPort>
+ <DevelopmentServerPort>51877</DevelopmentServerPort>
+ <DevelopmentServerVPath>/</DevelopmentServerVPath>
+ <IISUrl>
+ </IISUrl>
+ <NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
+ <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
+ </WebProjectProperties>
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <Import Project="$(SolutionDir)\tools\NuGet\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MongoDB.OData.SampleHost")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("MongoDB.OData.SampleHost")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f2c0bdf2-de8b-45fd-9d68-a470266145a1")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,3 @@
+
+
+<%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="MongoDB.OData.SampleHost.Sample" %>
@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Services;
+using System.Data.Services.Common;
+using System.Linq;
+using System.ServiceModel.Web;
+using System.Web;
+using MongoDB.Driver;
+using MongoDB.OData.SampleModels;
+
+namespace MongoDB.OData.SampleHost
+{
+ public class Sample : TypedMongoDataService
+ {
+ // This method is called only once to initialize service-wide policies.
+ public static void InitializeService(DataServiceConfiguration config)
+ {
+ TypedMongoDataService.Configure(config);
+
+ config.SetEntitySetAccessRule("*", EntitySetRights.All);
+ config.UseVerboseErrors = true;
+ }
+
+ protected override void BuildMetadata(TypedMongoDataServiceMetadata metadata)
+ {
+ metadata.SetContainer("MongoDB.Samples", "Blog");
+ metadata.AddResourceSet<Blog>("Blogs", "odata", "blogs");
+ metadata.AddResourceSet<Post>("Posts", "odata", "posts");
+ metadata.AddResourceSet<User>("Users", "odata", "users");
+ }
+
+ protected override MongoServer CreateDataSource()
+ {
+ var server = MongoServer.Create();
+
+ //create data if none exists...
+ var db = server.GetDatabase("odata");
+ var userCollection = db.GetCollection<User>("users");
+ var blogCollection = db.GetCollection<Blog>("blogs");
+ var postsCollection = db.GetCollection<Post>("posts");
+
+ if (userCollection.Count() > 0)
+ return server;
+
+ var user1 = new User
+ {
+ Id = Guid.NewGuid(),
+ FirstName = "Jack",
+ LastName = "McJack",
+ DisplayName = "jmcjack",
+ LastLoginDateUtc = new DateTime(2012, 5,17, 21, 53,32).ToUniversalTime()
+ };
+
+ var user2 = new User
+ {
+ Id = Guid.NewGuid(),
+ FirstName = "Jane",
+ LastName = "McJane",
+ DisplayName = "jmcjane",
+ LastLoginDateUtc = new DateTime(2012, 5, 16, 3, 24, 31).ToUniversalTime()
+ };
+
+ userCollection.InsertBatch(new[] { user1, user2 });
+
+ var blog = new Blog
+ {
+ Id = Guid.NewGuid(),
+ Author = new UserSummary { Id = user1.Id, DisplayName = user1.DisplayName },
+ Name = "Test Blog",
+ };
+
+ var post1 = new Post
+ {
+ Id = Guid.NewGuid(),
+ BlogId = blog.Id,
+ Title = "New OData Support",
+ Abstract = "MongoDB supports OData!!!",
+ Content = "MongoDB supports OData with the new MongoDB.OData provider",
+ PostTimeUtc = new DateTime(2012, 5, 13, 23, 47, 58).ToUniversalTime(),
+ Comments = new List<Comment>
+ {
+ new Comment { Id = Guid.NewGuid(), Author = new UserSummary { Id = user2.Id, DisplayName = user2.DisplayName }, Content = "Love it!!!" }
+ }
+ };
+
+ var post2 = new Post
+ {
+ Id = Guid.NewGuid(),
+ BlogId = blog.Id,
+ Title = "Updating with mongodb-dotnet-odata",
+ Abstract = "Updating with mongodb-dotnet-odata",
+ Content = "In order to update mongodb through odata, follow the below code samples.",
+ PostTimeUtc = new DateTime(2012, 5, 17, 22, 12, 14).ToUniversalTime()
+ };
+
+ blog.Posts.Add(new BlogPostSummary { Id = post1.Id, Abstract = post1.Abstract, Title = post1.Title, PostTimeUtc = post1.PostTimeUtc });
+ blog.Posts.Add(new BlogPostSummary { Id = post2.Id, Abstract = post2.Abstract, Title = post2.Title, PostTimeUtc = post2.PostTimeUtc });
+
+ blogCollection.Insert(blog);
+ postsCollection.InsertBatch(new[] { post1, post2 });
+
+ return server;
+ }
+ }
+}
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+
+<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
+
+<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
+ <!--
+ In the example below, the "SetAttributes" transform will change the value of
+ "connectionString" to use "ReleaseSQLServer" only when the "Match" locator
+ finds an atrribute "name" that has a value of "MyDB".
+
+ <connectionStrings>
+ <add name="MyDB"
+ connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
+ xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
+ </connectionStrings>
+ -->
+ <system.web>
+ <!--
+ In the example below, the "Replace" transform will replace the entire
+ <customErrors> section of your web.config file.
+ Note that because there is only one customErrors section under the
+ <system.web> node, there is no need to use the "xdt:Locator" attribute.
+
+ <customErrors defaultRedirect="GenericError.htm"
+ mode="RemoteOnly" xdt:Transform="Replace">
+ <error statusCode="500" redirect="InternalError.htm"/>
+ </customErrors>
+ -->
+ </system.web>
+</configuration>
Oops, something went wrong.

0 comments on commit 17e5f0a

Please sign in to comment.