1) let userRolesInGroup (group : Group) = query <@ seq{ for u in dataCtx.Users do
if u.Id = user.Id then
for role in dataCtx.Roles do
if role.GroupId = group.Id && role.Users.Contains(u) then
yield role} @>
throw
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at Microsoft.FSharp.Collections.MapTreeModule.find[TValue,a](IComparer
1 comparer, TValue k, MapTree2 m)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvObjArg(FSharpMap
2 env, FSharpOption1 objOpt, FSharpOption
1 coerceTo)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExpr(FSharpMap2 env, FSharpExpr inp)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvObjArg(FSharpMap
2 env, FSharpOption1 objOpt, FSharpOption
1 coerceTo)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExpr(FSharpMap2 env, FSharpExpr inp)
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc
2 mapping, FSharpList1 x)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExprs(FSharpMap
2 env, FSharpList1 es)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExpr(FSharpMap
2 env, FSharpExpr inp)
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc2 mapping, FSharpList
1 x)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExprs(FSharpMap2 env, FSharpList
1 es)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExpr(FSharpMap2 env, FSharpExpr inp)
at Microsoft.FSharp.Linq.QuotationEvaluation.ConvExpr(FSharpMap
2 env, FSharpExpr inp)
at Microsoft.FSharp.Linq.QuotationEvaluation.Compile[a](a e)
at Microsoft.FSharp.Linq.QuotationEvaluation.Expr.EvalUntyped(FSharpExpr )
at Microsoft.FSharp.Linq.QueryModule.query[T](FSharpExpr1 p)
Why exception? Should be null or None Value.
2)
let userRolesInGroup (group : Group) = query <@ seq{ for u in dataCtx.Users do
if u.Id = user.Id then
for role in u.Roles do
if role.GroupId = group.Id then
yield role} @>
throw
System.Exception: The following construct was used in query but is not recognised by the F#-to-LINQ query translator:
PropertyGet (Some (u),
System.Data.Objects.DataClasses.EntityCollection`1[DevGroups.Domain.Role] Roles,
[])
This is not a valid query expression. Check the specification of permitted queries and consider moving some of the query out of the quotation
at
Microsoft.FSharp.Linq.QueryModule.TransInner@639-4.Invoke(String message)
at
Microsoft.FSharp.Core.PrintfImpl.go@512-3[b,c,d](String fmt, Int32 len, FSharpFunc
2 outputChar, FSharpFunc2 outa, b os, FSharpFunc
2 finalize, FSharpList1 args, Int32 i)
at
Microsoft.FSharp.Core.PrintfImpl.run@510[b,c,d](FSharpFunc`2 initialize, String fmt, Int32 len, FSharpList
1 args)
at <StartupCode$FSharp-Core>.$Reflect.Invoke@617-4.Invoke(T1 inp)
at Microsoft.FSharp.Linq.QueryModule.TransInner@496(FSharpExpr tm)
at Microsoft.FSharp.Linq.QueryModule.TransMapConcatSelector@505(Type targetTy, Type srcTy, FSharpExpr sq, FSharpVar selectorVar, FSharpExpr t)
at Microsoft.FSharp.Linq.QueryModule.TransMapConcatSelector@505(Type targetTy, Type srcTy, FSharpExpr sq, FSharpVar selectorVar, FSharpExpr t)
at Microsoft.FSharp.Linq.QueryModule.EvalOuterWithPostProcess@643(FSharpExpr tm)
at Microsoft.FSharp.Linq.QueryModule.query[T](FSharpExpr1 p)