The EntitySpaces Community

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

Adding two column values toegether in query not possible?

Last post 04-29-2008, 10:58 PM by atrio services. 5 replies.
Sort Posts: Previous Next
  •  04-23-2008, 11:56 PM 9004

    Adding two column values toegether in query not possible?

    Hi,

    Back again with antoher problem/question:

    Code:
    1                MyNewsQuery.Select(MyNewsQuery, NewsItems.Title.As("NewsItemTitle"))
    2                MyNewsQuery.InnerJoin(NewsItems).On(MyNewsQuery.Id = NewsItems.IdNews)
    3                MyNewsQuery.Where(MyNewsQuery.Datedisplay.LessThanOrEqual(Now()))
    4                MyNewsQuery.Where(MyNewsQuery.Dateexpiration.GreaterThanOrEqual(Now()))
    5                MyNewsQuery.Where(MyNewsQuery.IdCategory.Equal(Category))
    6                MyNewsQuery.Where(MyNewsQuery.Datedisplay.GreaterThanOrEqual(Now().AddMonths(-2)))
    7                MyNewsQuery.Where(MyNewsQuery.Ndelaygroup.LessThanOrEqual(Level) Or (((MyNewsQuery.Datedisplay + MyNewsQuery.Delay) <= Now()) And MyNewsQuery.Delay <> 9))
    8                MyNewsQuery.OrderBy(MyNewsQuery.Datedisplay, esOrderByDirection.Descending)
    

     

    On line 7 I want to add a delay (number of days to delay the news item from being shown to everyone, which is stored in my table) to the datedisplay of my newsitem (also stored in my table). But on executing the query ES outputs "MyNewsQuery.Datedisplay + MyNewsQuery.Delay" as just the "datedisplay" without adding the "+ delay" to my query.

    Am I using the wrong syntax here to add two column values together in the query (Oracle DB) or is something going wrong in ES conversion to Oracle DB query?

    Thanks in advance for the replies!

     

    Filed under: ,
  •  04-24-2008, 4:41 AM 9007 in reply to 9004

    Re: Adding two column values toegether in query not possible?

    After you do the load please look at MyNewsQuery.es.LastQuery and post that here and let us take a look at the actual SQL, you can choose SQL instead of C# when you post it.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-24-2008, 5:01 AM 9008 in reply to 9004

    Re: Adding two column values toegether in query not possible?

    You can check collection.Query.es.LastQuery after collection.Load(MyNewsQuery) and see the exact SQL sent to the server. In this case you will discover that, in ES2007, expressions are only supported in Select() clauses, not Where() clauses. That is something we plan to address in ES2008, but not in the coming Beta. You will have to do your query as a custom Load() in your custom collection class.
    David Neal Parsons
    www.entityspaces.net
  •  04-25-2008, 5:59 AM 9020 in reply to 9008

    Re: Adding two column values toegether in query not possible?

    Is it actually possible to execute a query in plain text, and then load the results in an EntitySpaces object? If so, even when a join is involved?

  •  04-25-2008, 6:21 AM 9021 in reply to 9020

    Re: Adding two column values toegether in query not possible?

    Yes, and I'm sorry I haven't gotten back to you, to be sure, I will test and fix this for ES2008 if there is a problem found.

     

    Code:
    namespace BusinessObjects
    {
        public partial class CategoriesCollection : esCategoriesCollection
        {
            public bool CustomLoad(int id1, int id2)
            {
                return this.Load(esQueryType.Text,
                    "SELECT * FROM yada WHERE field1 = {0} AND field2 = {1}",
                    id1, id2); 
            }
        }
    }
     

    You can load EntitySpaces from any form of custom SQL you can dream up.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-29-2008, 10:58 PM 9106 in reply to 9021

    Re: Adding two column values toegether in query not possible?

    Thanks for that Mike! Greatly appreciated!
View as RSS news feed in XML