Hello, I am trying to resolve an issue which occurs when I try to do this query in LightSpeed (5.0.2625.0):
(from gm in Db.UnitOfWork.GroupMembers
join g in Db.UnitOfWork.Groups on gm.GroupId equals g.Id
join permission in Db.UnitOfWork.Permissions on gm.ObjectId equals permission.ObjectId into permissionGrp
from p in permissionGrp.DefaultIfEmpty()
let isAllowed = allowed
where
g.DrScId == drScId && g.ObjectType == 3 && scope.Contains(g.EntityId) &&
((p==null && isAllowed) || (p!=null && (p.UserId==userId || p.UserId==null) && (p.GroupId==null || groups.Contains(p.GroupId))))
select new { gm.ObjectId, p }).ToList();
- This query works when compiled on Windows with the Microsoft
System.dll
.
- An exception only occurs when running on Mono. I have tried targetting 3.5 / 4 and 4.5.
The exception:
Object reference not set to an instance of an object
at System.ComponentModel.BindingList`1[MyCompany.MyProject.Model.Permission].InsertItem (Int32 index, MyCompany.MyProject.Model.Permission item) [0x00037] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/System/System.ComponentModel/BindingList.cs:246
at Mindscape.LightSpeed.EntityCollection`1[MyCompany.MyProject.Model.Permission].InsertItem (Int32 index, MyCompany.MyProject.Model.Permission item) [0x00000] in <filename unknown>:0
at System.Collections.ObjectModel.Collection`1[MyCompany.MyProject.Model.Permission].System.Collections.IList.Add (System.Object value) [0x0000c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Collections.ObjectModel/Collection.cs:210
at .. (Mindscape.LightSpeed.Model.AliasedTypeModel , Mindscape.LightSpeed.Querying.QueryExpression , Mindscape.LightSpeed.Querying.Order , Mindscape.LightSpeed.Querying.Group , System.String , Boolean , Boolean ) [0x00000] in <filename unknown>:0
at .. (Mindscape.LightSpeed.LightSpeedContext , System.Collections.Generic.List`1 , Mindscape.LightSpeed.Querying.QueryExpression , Mindscape.LightSpeed.Querying.Order , Mindscape.LightSpeed.Querying.Group , System.String , Boolean , Boolean ) [0x00000] in <filename unknown>:0
at .. (Mindscape.LightSpeed.Model.AliasedTypeModel , IList , System.String , Boolean ) [0x00000] in <filename unknown>:0
at .. (System.Collections.Generic.List`1 , Mindscape.LightSpeed.EntityTuple , System.String , Boolean ) [0x00000] in <filename unknown>:0
at .. (System.Collections.Generic.List`1 , Mindscape.LightSpeed.Querying.Query , Mindscape.LightSpeed.EntityTuple ) [0x00000] in <filename unknown>:0
at .. (Mindscape.LightSpeed.UnitOfWorkBase , System.Collections.Generic.List`1 , Mindscape.LightSpeed.Querying.Query , Mindscape.LightSpeed.EntityTuple ) [0x00000] in <filename unknown>:0
at .. (Mindscape.LightSpeed.Querying.Query , System.Collections.Generic.List`1 , Mindscape.LightSpeed.EntityTuple ) [0x00000] in <filename unknown>:0
at .. (Mindscape.LightSpeed.Querying.Query , Mindscape.LightSpeed.EntityTuple ) [0x00000] in <filename unknown>:0
at Mindscape.LightSpeed.UnitOfWork.FindGroup (Mindscape.LightSpeed.Querying.Query query, Mindscape.LightSpeed.EntityTuple results) [0x00000] in <filename unknown>:0
at Mindscape.LightSpeed.UnitOfWorkBase.Find (Mindscape.LightSpeed.Querying.Query query, Mindscape.LightSpeed.Querying.EntityMap typeMap) [0x00000] in <filename unknown>:0
at Mindscape.LightSpeed.Linq.Plan.SingleQueryPlan.ExecuteImmediate (IUnitOfWork unitOfWork, System.Type returnType) [0x00000] in <filename unknown>:0
at Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0
at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0
at Mindscape.LightSpeed.Linq.LinqQuery`1[MyCompany.MyProject.Result].GetEnumerator () [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[MyCompany.MyProject.Result].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Collections.Generic/List.cs:132
at System.Collections.Generic.List`1[MyCompany.MyProject.Result]..ctor (IEnumerable`1 collection) [0x0002f] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/corlib/System.Collections.Generic/List.cs:69
at System.Linq.Enumerable.ToList[Result] (IEnumerable`1 source) [0x00006] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.5/mcs/class/System.Core/System.Linq/Enumerable.cs:2951
at MyCompany.MyProject.MainClass.Main () [0x00a48] in Program.cs:42
Now I know you guys don't directly support Mono, but I am in the unfortunate position where I have identified what looks to be a discrepancy with the way null
is handled between Microsoft's implementation of System.ComponentModel.BindingList<T>
and Mono's implementation. But as this issue only seems to occur with object inheriting from LightSpeed.Entity
and I can't set breakpoints in this code, it's a bit of a black box as to what is going wrong. I want to be able to report the issue to Mono because this is fundamentally breaking LightSpeed for me.
The simplest case to reproduce the error, without a model, is just creating a new BindingList
of LightSpeed.Entity
and trying to add null
.
var bl = new System.ComponentModel.BindingList<Mindscape.LightSpeed.Entity>();
bl.Insert(0, null);
Your help would be greatly appreciated, as I can't find any way around using this query.