The EntitySpaces Community

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

DefaultConjuction.Or appears broken in Release 2007.1.1119.0

Last post 03-11-2008, 1:34 PM by David.Parsons. 4 replies.
Sort Posts: Previous Next
  •  03-10-2008, 2:40 AM 8349

    DefaultConjuction.Or appears broken in Release 2007.1.1119.0

    Up until upgrading to this release, I've had the following code which has worked fine:

     

    Code:
                task.Query.es.DefaultConjunction = esConjunction.Or;
                task.Query.Where
                    (
                    task.Query.And(task.Query.EventCode.Equal(jobTask.EventCode), task.Query.JobTypeID.Equal(jobTask.JobID)),
                    task.Query.And(task.Query.EventCodeOnFail.Equal(jobTask.EventCode), task.Query.JobTypeID.Equal(jobTask.JobID))
                    );


     However that now results in the following SQL:

     

    Code:
    exec sp_executesql N'SELECT * FROM [Task] WHERE (([EventCode] = @EventCode1 AND [JobTypeID] = @JobTypeID2))(([EventCodeOnFail] = @EventCodeOnFail3 AND [JobTypeID] = @JobTypeID4))',N'@EventCode1 
    nvarchar(12),@JobTypeID2 int,@EventCodeOnFail3 nvarchar(12),@JobTypeID4 int',@EventCode1=N'Final Review',@JobTypeID2=66701,@EventCodeOnFail3=N'Final Review',@JobTypeID4=66701
    
     

     Notice there is no OR in-between the two ANDed parts to the query.

     
    This code results in the correct syntax once more:

    Code:
                task.Query.Where(
                        task.Query.Or(
                            task.Query.And(task.Query.EventCode.Equal(jobTask.EventCode), task.Query.JobTypeID.Equal(jobTask.JobID)),
                            task.Query.And(task.Query.EventCodeOnFail.Equal(jobTask.EventCode), task.Query.JobTypeID.Equal(jobTask.JobID))
                        )
                    );

    Now I just have to go through my code and find where I've used Or as a defaultConjunction.

     
    Cheers,

    Dave.
     

  •  03-10-2008, 3:11 AM 8350 in reply to 8349

    Re: DefaultConjuction.Or appears broken in Release 2007.1.1119.0

    Looking into it further, it appears this defect only occurs when mixing conjunctions (both AND and OR) together.

    Default conjuction OR works fine on it's own. 

  •  03-10-2008, 4:32 AM 8351 in reply to 8350

    Re: DefaultConjuction.Or appears broken in Release 2007.1.1119.0

    I think we fixed this issue however on Version 2007.1.1210.0 which was the final ES2007 release. However, even better, our new syntax is strongly encouraged and a far superior way of writing Where clauses (it's in your build)

     

    Code:
    // Before
    task.Query.Where
    (
    task.Query.And(task.Query.EventCode.Equal(jobTask.EventCode), task.Query.JobTypeID.Equal(jobTask.JobID)),
    task.Query.And(task.Query.EventCodeOnFail.Equal(jobTask.EventCode), task.Query.JobTypeID.Equal(jobTask.JobID))
    );
     

    After

     

    Code:
    task.Query.Where
    (
    task.Query.EventCode == jobTask.EventCode & task.Query.JobTypeID == jobTask.JobID,
    task.Query.EventCodeOnFail == jobTask.EventCode & task.Query.JobTypeID == jobTask.JobID
    );
     

    I don't know about you but I would much rather write queries like the After example, you can use (a single) & or AND and | for OR and then use the natural language syntax, ie, ==. >=, <= and so on ...

    You can mix AND and OR like this:

    Where( (X | Y) & (B | C) )

    in your queries, using parentheses, it works great !! Yes 

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-11-2008, 5:58 AM 8378 in reply to 8351

    Re: DefaultConjuction.Or appears broken in Release 2007.1.1119.0

    It's a rather large codebase from ES 1.5.X days...    I upgrade when I can to the different builds, but I've got to admit, the new version numbers (in ES2007) mean less to me than the old point releases. Also I've tended to just change code when the build breaks each time I upgrade and refactor as the code changes.

    That said, yeah... I do prefer your after example. Will get into using that a lot more.

    Can you use both boolean and bitwise operators? Or just the bitwise ones?
     

  •  03-11-2008, 1:34 PM 8384 in reply to 8378

    Re: DefaultConjuction.Or appears broken in Release 2007.1.1119.0

    As to the EntitySpaces versioning scheme, we just posted this FAQ:

    While it comes a little late for you, the new scheme can help you in your upgrade decisions. For example, when presented with the choice of upgrading to 2007.1.1119.0 or 2007.1.1210.0, then 2007.1.1210.0 is the better choice. It contains the latest enhancements and fixes, but no additional breaking changes over the 1119 version.

    As to your question, that bug was fixed in 2007.1.1210.0, and it still supports both methods.


    David Neal Parsons
    www.entityspaces.net
View as RSS news feed in XML