object / MongOData

MongoDB OData provider
42 stars 5 forks source link

Conflict with Azure table storage assembly. #4

Open terencecraig opened 11 years ago

terencecraig commented 11 years ago

Hi,

First thanks for this package it is very useful.

I wanted to let you know about an issue I found and an (untested solution).

If you have a Silverlight client that is hosted in a web site and you then use that website as the basis of an Azure web role there will be a compile error caused by a dll conflict. This conflict is caused by the WindowsAzure.Storage package that will be added by VS to the web site on the creation of the web role.

Here are my changes to the generated MongoDataService that appear to fix it. I am going to try it out over the next couple of days will let you know if its causes problems.

Terence

/*
 * Extern is required because of the conflict documented here 
 * http://stackoverflow.com/questions/10675104/using-microsoft-data-services-client-dll-instead-of-system-data-services-client?lq=1
 * This is the solution that I used. 
 * http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx
 * 
 * 
 * 
 * 
 */
//Patch:This alias needs to be defined on Microsoft.Data.Services.Client
extern alias DataServicesClient;  
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Services;
using System.Data.Services.Common;
using Mongo.Context.Queryable;

namespace PBI.SL.Web
{
    public class MongoDataService : MongoQueryableDataService
    {
        public MongoDataService()
            : base(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString)
        {
        }

        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            //Patch: Alias needs to be used here
            config.DataServiceBehavior.MaxProtocolVersion = DataServicesClient::System.Data.Services.Common.DataServiceProtocolVersion.V3;
            config.DataServiceBehavior.AcceptCountRequests = true;
            config.DataServiceBehavior.AcceptProjectionRequests = true;
            config.UseVerboseErrors = true;
        }
    }
}
object commented 11 years ago

Hi Terence,

Thank you for the report. It's very interesting that you are using MongOData in Azure environment, and of course I would like to fully support this scenario.

The reason MongOData replaces System.Data.Services with Microsoft.Data.Service is to be able to support OData v.3 protocol that comes with some very useful features for MongoDB (e.g. support for array properties). It's unfortunate that Azure SDK still demands System.Data.Services. If you manage to get it to work, please let me know, I will either make an alternative package for Azure or will try to combine support for Azure in the main one.

Vagif

terencecraig commented 11 years ago

Hi,

Thanks for the reply the code I posted above compiles but doesn't work. But I think I might be able to fix it by updating windows azure storage to 2.0 and Odata to RC3. I modified the master sln and it is compiling. I will test it let you know.

Cheers,

Terence

terencecraig commented 11 years ago

Sorry didn't mean to close the issue and don't know how to reopen it without another comment.

terencecraig commented 11 years ago

Updating to table storage 2.0 and Odata RC3 seems to fix the issues. All tests pass except for 4 update tests that are failing in Simple.OData example failure message included below.

Since I am github ignorant I wrapped the project up in a rar and placed it on my google drive. https://docs.google.com/file/d/0B-4G7LNhZ_w-QzEyb3RDNzU2Z3c/edit?usp=sharing I will integrate into our app this week and let you know how it goes.

Once again thanks for this project. It saved us a lot of work.

Best,

Terence

Error Message: The update product doesn't have correct ReleaseDate. Expected: 14 But was: 13

Exception Message: The update product doesn't have correct ReleaseDate. Expected: 14 But was: 13

StackTrace: at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args) at NUnit.Framework.Assert.AreEqual(Int32 expected, Int32 actual, String message) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Mongo.Context.Tests.UpdateTests`1.UpdateMultipleFields() in s:\Projects\PatternBuildersAzure\MongOData-master\Mongo.Context.Tests\UpdateTests.cs:line 51

Output: Simple.Data.OData.Warnings: Non-UTC DateTime specified to EdmTypeSerializer Simple.Data.OData.Warnings: Non-UTC DateTime specified to EdmTypeSerializer

object commented 11 years ago

Hi Terence,

Thanks for the details. I've downloaded the shared RAR file, since I can only see there MongOData source files I assume you made changes to some of them. I would like to set up my own Azure environment to be able to test it myself. Can you brief me about your Mongo Azure setup (I never tried this combination), or point me to some docs so I can set it up in a similar way to yours.

Cheers Vagif

terencecraig commented 11 years ago

Hi Vagif,

I just changed the nuget package references to point to the right packages in the various projects to support Azure Tables 2.0 http://blogs.msdn.com/b/windowsazurestorage/archive/2012/11/06/windows-azure-storage-client-library-2-0-tables-deep-dive.aspx and removed the old ones. There were no source changes.

Regarding Mongo by far the easiest way to get Mongo running on Azure is to allocate a VM and then rdp in and install Mongo as usual. Mongo has an installer that will set up replica sets on VMs for you but I have never used it. http://docs.mongodb.org/ecosystem/tutorial/install-mongodb-on-windows-azure/

A little more complex but not much is to set up Mongo on worker roles which is the way that most people will be using Mongo on Azure and the way that we do it in most cases. Mongo has good guidance and an example project here (http://docs.mongodb.org/ecosystem/tutorial/deploy-mongodb-worker-roles-in-azure/#deploy-mongodb-worker-roles-in-azure).

Shoot me an email if you have problems ( git at patternbuilders.com ) and I will try and help out.

Best,

Terence

terencecraig commented 11 years ago

PS I also upgraded the solution to VS 2012.

object commented 11 years ago

Thank you for the tips regarding Azure setup with MongoDB. I will set it up to start reproducing issues myself.