The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

This used to work

Last post 08-28-2008, 1:47 PM by paschoal1. 5 replies.
Sort Posts: Previous Next
  •  08-26-2008, 9:15 AM 10921

    This used to work

     This used to work.

    I am using Es 2008.

    this = PosicaoCotista

    I am getting  --> NullReferenceException: Object reference not set to an instance of an object

     

    Code:
    1                this.Query
    2                    .Select(this.query.IdCotista.Count().Distinct())
    3                    .Where(this.query.IdCarteira == idCarteira,
    4                          (this.query.Quantidade. + this.query.QuantidadeBloqueada != 0)
    5                    );
    6                this.Query.Load();
        
    

  •  08-26-2008, 9:30 AM 10922 in reply to 10921

    Re: This used to work

    Well, when you say that something used to work it's customary to post what you were using before and after? Did you upgrade? Also, whats with the extra "." after Quantidade in the Where statement?
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-26-2008, 9:45 AM 10928 in reply to 10922

    Re: This used to work

    Sorry. I was not find the version that i am using now.

    Ok. Here it is:

    ES V2008.1.0623.0

    The dot after quantidade is a mistake. it does not exist.

     The correct code is it.

    Code:
    1    this.Query
    2          .Select(this.query.IdCotista.Count().Distinct())
    3          .Where(this.query.IdCarteira == idCarteira,
    4                     (this.query.Quantidade + this.query.QuantidadeBloqueada != 0)
    5           );
    6    this.Query.Load();
    

    This code used to work in the last version of Es2007.
    The error now is NullReferenceException: Object reference not set to an instance of an object
  •  08-27-2008, 1:33 PM 10979 in reply to 10928

    Re: This used to work

    Do you have time to look at this?

    I am not willing to do the query another way.

     

  •  08-27-2008, 5:27 PM 10985 in reply to 10979

    Re: This used to work

    Okay, I tried this in ES2008 and indeed it doesn't work. I reviewed our history in subversion and that particular area has not changed in quite some time. I went back and tried in on ES2007 and it crashes as well, so I'm not sure what you are seeing. The enhancement is non trivial and we knew this was there actually. Major DynamicQuery enhancements (yes even more power) are coming in ES2009. However, it appears this didn't work in ES2007.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-28-2008, 1:47 PM 11015 in reply to 10985

    Re: This used to work

    Well, I am almost sure that it worked someday in the past.

    But, now here is the workaround to achieve the same result.

    I have to do a subquery.

     

    Code:
    1                PosicaoCotistaQuery posicaoCotistaQuery = new PosicaoCotistaQuery("p");
    2                PosicaoCotistaQuery posicaoCotistaSubQuery = new PosicaoCotistaQuery("p1");
    3    
    4                string column = "<count(distinct sub." + PosicaoCotistaMetadata.ColumnNames.IdCotista + ") as IdCotista>";
    5    
    6                posicaoCotistaQuery.Select("" + column + "");
    7                //
    8                posicaoCotistaQuery.From
    9                    (
    10                       posicaoCotistaSubQuery.Select(posicaoCotistaSubQuery.IdCarteira, 
    11                                                                      posicaoCotistaSubQuery.IdCotista,
    12                                                                      (posicaoCotistaSubQuery.Quantidade + posicaoCotistaSubQuery.QuantidadeBloqueada).As("Quantidade"))
    13                                             .Where(posicaoCotistaSubQuery.IdCarteira == idCarteira &
    14                                                        posicaoCotistaSubQuery.Quantidade != 0)                                                 
    15                   ).As("sub");
    16   
    17               PosicaoCotistaCollection posicaoCotistaCollection = new PosicaoCotistaCollection();
    18               posicaoCotistaCollection.Load(posicaoCotistaQuery);
    19   
    
     

     

     

     

View as RSS news feed in XML