Exception when using Member extension method

Oct 4, 2013 at 6:06 PM
Hello

I have tried your SDX examples for WHERE and Member extension method (
https://ssasefprovider.codeplex.com/discussions/455778)
and they work OK, but, when using variable instead of fixed string value, like this:
void TestQuery1()
 {
   var member = "Italy";
   var qq = from orderHeader in context.Orders
                     from order in context.OrderDetails
                     where orderHeader.ShipCountry.Member(member)
                     select new { order.Quantity };
  var qql = qq.ToList();
  foreach (var q in qql)
     Console.WriteLine("{0} ", q.Quantity);
}
I receive EntityCommandCompilationException. Here is a strack trace (here Ii put COMPANYNAME and PERSONEMAIL instead of the company name and person who bought the licence):

Unhandled Exception: System.Data.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details. ---> System.InvalidCastException: Unable to cast object of type 'System.Data.Common.CommandTrees.DbParameterReferenceExpression' to type 
    'System.Data.Common.CommandTrees.DbConstantExpression'.System.Linq.Enumerable+<RepeatIterator>d__bc`1[System.String]COMPANYNAME#COMPANYNAME#PERSONEMAIL ---> System.InvalidCastException: Unable to cast object of type 'System.Data.Common.CommandTrees.DbParameterReferenceExpression' to type 'System.Data.Common.CommandTrees.DbConstantExpression'.
   at A.FP.GC(DbComparisonExpression )
   at A.FP.GC(DbComparisonExpression )
   at A.FP.Visit(DbComparisonExpression comparisonExpression)
   at System.Data.Common.CommandTrees.DbComparisonExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
   at A.FP.FC(EO , DbExpression )
   at A.ZO.GC(DbExpression , DbExpressionBinding , Boolean )
   at A.ZO.Visit(DbFilterExpression e)
   at (Object , DbFilterExpression )
   at A.LSB.B(Object , DbFilterExpression )
   at A.FP.Visit(DbFilterExpression e)
   at System.Data.Common.CommandTrees.DbFilterExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
   at A.ZO.GC(XO , AO& )
   at A.FP.GC(DbProjectExpression )
   at A.FP.Visit(DbProjectExpression e)
   at System.Data.Common.CommandTrees.DbProjectExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
   at A.ZO.GC(DbExpression , Boolean )
   at A.ZO.GC(DbQueryCommandTree )
   at A.FP.GC(DbCommandTree , AN , IDictionary`2& )
   at AgileDesign.SsasEntityFrameworkProvider.SsasProvider.B(DbProviderManifest , DbCommandTree )
   at AgileDesign.SsasEntityFrameworkProvider.SsasProvider.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
   --- End of inner exception stack trace ---
   at AgileDesign.SsasEntityFrameworkProvider.SsasProvider.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
   at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
   at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
   --- End of inner exception stack trace ---
   at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
   at System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
   at System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
   at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
   at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters, AliasGenerator aliasGenerator)
   at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Data.Entity.Internal.Linq.InternalQuery`1.GetEnumerator()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at UsageExample.QueryRunner.TestQuery1() in c:\Users\ttustonic\Documents\Visual Studio 2012\Projects\CubeTest1\ExampleLibrary\QueryRunner.cs:line 65
   at UsageExample.QueryRunner.RunQuery() in c:\Users\ttustonic\Documents\Visual Studio 2012\Projects\CubeTest1\ExampleLibrary\QueryRunner.cs:line 45
   at UsageExample.Program.Main() in c:\Users\ttustonic\Documents\Visual Studio 2012\Projects\CubeTest1\UsageExample\Program.cs:line 15
I am using SsasEntityFrameworkProvider ver. 2.5.4

Thanks,
Tom
Oct 11, 2013 at 12:48 AM
Edited Oct 11, 2013 at 12:48 AM
Thank you for the information Tom

-Indeed, WHERE and parametrized Member() extension method did not work in ver. 2.5.4.
Today we have released a new version 2.5.5 which fixes this issue. It is available via both NuGet and as MSI at http://agiledesignllc.com/download/SsasEntityFrameworkProviderSetup.msi
Marked as answer by ttustonic on 10/10/2013 at 4:56 PM
Oct 11, 2013 at 12:53 AM
grand wrote:
Today we have released a new version 2.5.5 which fixes this issue. It is available via both NuGet and as MSI at
Great!
Thanks, I'll try it ASAP

Cheers,
Tom