Weird problem using Where in query

Aug 30, 2013 at 3:04 PM
Hello
I have a weird problem with the query using 'where'.
My Context for the cube is hand-written, similarly to NorthwindEFContext in ExampleLibrary project.
My [MeasureGroup] and User classes look like
    [Table("fInvoice")]
    [MeasureGroup]
    public partial class Invoice
    {
        [DimensionProperty("Issuers")]
        public int IssuerID { get; set; }
        [DimensionProperty("Services")]
        public int ServiceID { get; set; }
        [DimensionProperty("Users")]
        public int UserID { get; set; }
        [DimensionProperty("AnalyticalAccounts")]
        public int AnalyticalAccountID { get; set; }
        [Column("SumAmount")]
        public decimal? Amount { get; set; }
        [Column("fInvoiceCount")]
        public int? Count { get; set; }
    }

    public partial class User
    {
        [Key]
        public string OIB { get; set; }
        public string FullName { get; set; }
    }
My LINQ query is:
var q = (
 from user in ctx1.Users
 from inv in ctx1.Invoices
 where (user.OIB == "0123456789")     // ver.1
//                         where (user.FullName == "Firstname Surname")   // ver.2
 select new 
 {
   Name = user.FullName,  OIB = user.OIB,  Count = inv.Count
   })   .ToArray()

  foreach (var a in q)
  {
     Console.WriteLine(" {0} :: {1} :: {2} ", a.Name, a.OIB, a.Count);
  }
This query works OK, but, if I comment out the ver.1 part of the query and include ver.2 part, then I get NullReferenceException in the loop. Obviously, values for OIB and FUllName properties describe the same user.
Array q has a correct number of elements, but all of them are always null.

Both generated MDX queries work OK and give the same result in both cases.
WITH MEMBER [Measures].[C1]        AS 1
SELECT NON EMPTY
FILTER
((
[User].[Full Name].[Full Name],
[User].[OIB].[OIB]
),
-- [User].[OIB].MemberValue = '0123456789'  -- ver.1
[User].[Full Name].MemberValue = 'Firstname Surname'  -- ver.2
)ON ROWS,
{
[Measures].[C1],
[Measures]. [f Invoice Count]
}
ON COLUMNS
FROM [fInvoice]
What could be the problem here?

Thanks in advance, Tom
Coordinator
Aug 30, 2013 at 7:15 PM
Edited Aug 30, 2013 at 7:16 PM
Dear Tom,

We are sorry to hear about such an issue.

Unfortunately it will be impossible to answer your question without a sample project that reproduces the issue. I assume where clause is only broken for User.FullName property, and works for any other property, correct?

If you could send us a full exception stack trace together with a maximally simplified project sample that reproduces the issue (both C# and cube DB definition XMLA with sample data) to info@AgileDesignLlc.com, we would definitely look into this issue.
Even the full exception stack trace alone might appear to be useful.

Thanks.
Sep 3, 2013 at 10:22 AM
Hello

Here is a stack trace, although I don't think it will be very useful:
   at SdxWalkthrough.Program.Test3() in xxxx\CubeTest1\Program.cs:line 74
   at SdxWalkthrough.Program.Main() in xxxx\CubeTest1\Program.cs:line 33
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
While I was creating a demo project to reproduce a bug I created a backup of the cube and restored it on my development machine, removed personal info from the data and when I tried with the demo cube, all the queries run fine!
However, I noticed something that I didn't notice before.
The results for the generated MDX queries which are OK (ver.1) have value 1 for the C1, while the bad one has null, like :
                  |             | C1   | f Invoice Count
---------------------------------------------------
Firstname Surname | 0123456789 | null  | 2
So, in conclusion... I'm unable to produce a working demo which reproduces problem. Unfortunately, I can't give you the original cube since it contains some sensitive data. Perhaps you have an idea what causes the difference in C1? It looks like it might be a reason for the exception. I guess there might be a problem with the original cube, but, since I've never worked with cubes before it'll take a time to find out.

Thanks, Tom
Coordinator
Sep 3, 2013 at 2:14 PM
Edited Sep 3, 2013 at 2:34 PM
Thank you for the information Tom.

We have 2 more questions:
  1. If you run your project that has the NullRreferenceException problem on a new different machine, does it run fine?
  2. Are you running the project on .NET 4.x or x64? (If you are, you might try to run on .NET 2.0-3.5 x32 - if that happens to make a difference we will release a patch).
As a temporary work-around you can copy-paste the generated raw MDX and run it via AdomdExtensions library that comes with our product as described here.
Sep 3, 2013 at 3:21 PM
grand wrote:
Thank you for the information Tom.

We have 2 more questions:
  1. If you run your project that has the NullRreferenceException problem on a new different machine, does it run fine?
I don't have other machine available atm. Will try to get some and test.
  1. Are you running the project on .NET 4.x or x64? (If you are, you might try to run on .NET 2.0-3.5 x32 - if that happens to make a difference we will release a patch).
The original project is .NET 4 / x86, running on 64bit Windows 7. When I change to .NET 3.5 I get a bunch of compile errors The type or namespace name 'AgileDesign' could not be found. The same happens in the ExampleLibrary and UsageExample which come with the download. Also, I'm not sure how can I run on .NET 2? I believe that EF needs at least .NET 3.5, or am I missing something?
As a temporary work-around you can copy-paste the generated raw MDX and run it via AdomdExtensions library that comes with our product as described here.
Yes, I was already looking at that.
Thanks, Tom
Coordinator
Sep 3, 2013 at 6:09 PM
Edited Sep 3, 2013 at 6:13 PM
I'm unable to produce a working demo which reproduces problem. Unfortunately, I can't give you the original cube since it contains some sensitive data
-You could produce the project that demonstrates the issue by taking an original project with the issue and stripping down all irrelevant parts from both the source code and the cube. (I would run some test often to make sure the latest stripped part is irrelevant indeed). I realize that it may be time consuming, but just in case if you decide to do it.
I don't have other machine available atm. Will try to get some and test.
-Virtual machine should be enough - just FYI.
When I change to .NET 3.5 I get a bunch of compile errors The type or namespace name 'AgileDesign' could not be found.
-Our DLL-s are built as .NET 3.5 as of now, so it should be due to some of your own projects being not switched to 3.5.
Also, I'm not sure how can I run on .NET 2? I believe that EF needs at least .NET 3.5, or am I missing something?
-Yes, you are right of course. I meant that .NET 2.0 and 3.5 are basically the same, because they are running the same .NET Framework core, but I should have skipped .NET 2.0 in my answer - I am sorry for the confusion.
Sep 4, 2013 at 5:45 PM
grand wrote:
I'm unable to produce a working demo which reproduces problem. Unfortunately, I can't give you the original cube since it contains some sensitive data
-You could produce the project that demonstrates the issue by taking an original project with the issue and stripping down all irrelevant parts from both the source code and the cube. (I would run some test often to make sure the latest stripped part is irrelevant indeed). I realize that it may be time consuming, but just in case if you decide to do it.
Yes, however, in queries above both _Full name _and OIB are both sensitive and relevant (these are real people names and their unique personal identification numbers in my country), so I can't just strip it down.
Anyway, thanks for all your answers. Unfortunately I'm quite pressed with time at the moment, so I can't afford to test and debug on various machines and .NET versions. I'll probably find some workaround for this. Restored cubes on my dev machine consistently work OK, so, hopefully, this could be a fix on the production machine too. Fortunately, there's not much data there, yet :)

Thanks, Tom