Ask a questionAsk a question
 

Answer'Where' clause in views

  • Wednesday, November 04, 2009 12:20 PMCaelius Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I am having problems using 'where' clause in views. See code below.

    type Person
    {
      PersonId : Integer64;
      FName : Text#25;
    } where identity PersonId;

    Persons : Person*;

    PersonView() { from Person in Persons select { FName => Person.FName } where value.PersonId > 10 }

    It works ok as long as there is no 'where' clause in PersonView(). When the clause is added, intellipad throws an error below:

    -----------------------------------------------------
    Microsoft.Internal.Invariant+InternalException: An internal error has occurred:
       at Microsoft.Internal.Invariant.Fail(String description)
       at Microsoft.Internal.Invariant.Assert(Boolean condition)
       at Microsoft.M.SqlGen.RelationBindingHelper.BindRelationColumns(SqlCreatorContext context, RelationBinding binding, IEnumerable`1 columns)
       at Microsoft.M.SqlGen.BoundSqlExpressionOptimizations.OptimizeFromTableViewOrFunctionSubSelect(SqlCreatorContext context, FromItem fromItem, RelationBinding binding)
       at Microsoft.M.SqlGen.SqlExpressionCreator.GenerateFromQueryExpression(FromExpressionSymbol from, QuerySpecification querySpec, HashSet`1 dependencies)
       at Microsoft.M.SqlGen.SqlExpressionCreator.GenerateQueryExpression(IExpressionSymbol queryStart)
       at Microsoft.M.SqlGen.SqlExpressionCreator.GenerateFromExpression(FromExpressionSymbol from)
       at Microsoft.Internal.MethodInfoExtensions.FuncCastingStub`6.Call(T1Sig t1, T2Sig t2)
       at Microsoft.M.TermDispatcherFunc`4.Invoke(TDiscriminator discriminator, T1 arg1, T2 arg2)
       at Microsoft.M.SqlGen.SqlExpressionCreator.Generate(IExpressionSymbol expression)
       at Microsoft.M.SqlGen.SqlExpressionCreator.ForceQuery(IExpressionSymbol expression)
       at Microsoft.M.SqlGen.SqlViewFunctionCreator.FinalizeViewOrFunction(ComputedValue computedValue)
       at Microsoft.M.SqlGen.SqlCreator.FinalizeFunctionsAndViews(SqlCreatorContext context, Module module)
       at Microsoft.M.SqlGen.SqlCreator.DefineImplementations(SqlCreatorContext context, IEnumerable`1 modules)
       at Microsoft.M.SqlGen.SqlCreator.CreateSql(SqlCreatorContext context, Program originalProgram, SymbolResolver originalResolver, IEnumerable`1 references, CatalogCreator catalogCreator)
       at Microsoft.M.SqlGen.SqlCreator.CreateSql(Program program, SymbolResolver resolver, IEnumerable`1 references, CatalogCreator catalogCreator)
       at Microsoft.M.LanguageServices.MProjectStateMachine`2.GenerateDatabaseHelper()
       at Microsoft.M.LanguageServices.MProjectStateMachine`2.GenerateDatabasePending.<OnEnterState>b__35(Object o)
    -----------------------------------------

    Any idea, what i am doing wrong?


    Regards,

    Caelius

Answers

  • Thursday, November 05, 2009 4:32 PMGudgeMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Did you mean to write this;

       PersonView() { from Person in Persons where value.PersonId > 10 select { FName => Person.FName } }

    or did you really mean to put a constraint on the returned entity?

    Gudge
    • Proposed As Answer bydmatsonMSFTThursday, November 05, 2009 4:38 PM
    • Marked As Answer byCaelius Thursday, November 05, 2009 11:50 PM
    •  

All Replies

  • Thursday, November 05, 2009 4:32 PMGudgeMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Did you mean to write this;

       PersonView() { from Person in Persons where value.PersonId > 10 select { FName => Person.FName } }

    or did you really mean to put a constraint on the returned entity?

    Gudge
    • Proposed As Answer bydmatsonMSFTThursday, November 05, 2009 4:38 PM
    • Marked As Answer byCaelius Thursday, November 05, 2009 11:50 PM
    •  
  • Thursday, November 05, 2009 11:51 PMCaelius Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    That solves the problem for now, thanks. -Caelius