Search   

Sunday, February 05, 2012

Support » Support Forum

Register  Login

 Menu  
 
    

 Welcome!  
 


Welcome to the NDO support forum!

kreis.gif Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender.
kreis.gif Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts.
kreis.gif The forum software requires that javascript is enabled.
kreis.gif Please do not insert licence information or licence keys in forum posts.
kreis.gif If you know a good answer to a post of another user, feel free to reply!
kreis.gif The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.

   Print   

      
 NDO Support Forum  
 
SearchForum Home
  NDO-Forum postings in english please, if possible.  Developing with NDO  Aggregatfunctio...
 Aggregatfunctions and DateTime-fields
 
 9/26/2006 2:23:57 PM
UweR
1 posts


Aggregatfunctions and DateTime-fields
How can I use aggregatfunctions like min or max with DateTime-fields?
 9/26/2006 5:16:14 PM
Mirko
109 posts
5th


Re: Aggregatfunctions and DateTime-fields
 Modified By Mirko  on 9/26/2006 5:23:32 PM)

Hi Uwe,

I'm sorry, that's not possible at the moment. We plan to support aggregate functions on DateTime values in the next bigger release of NDO. For a workaround, you have several possibilities. The first one is to use ADO.NET. Note, that you can use the NDO.Mapping API to decouple the table and column names from your application. The second choice is to use a persistent class with only one DateTime field and fetching an object using a Sql pass-through query:

[NDOPersistent]
public class DateTimeContainer
{
    DateTime date;
    DateTime Date { get { return date; } }
}

// Calling context
string sql = String.Format("SELECT MAX({0}) AS [Date] FROM {1}", columnName, tableName);
Query q = pm.NewQuery(typeof(DateTimeContainer),  sql, false, Query.Language.Sql);
DateTimeContainer dtc = (DateTimeContainer) q.ExecuteSingle();
// dtc.Date contains your date. Should be DateTime.MinValue, if the resultset was emtpy

Hope that helps!

Best Regards:
Mirko

  NDO-Forum postings in english please, if possible.  Developing with NDO  Aggregatfunctio...
  SearchSearch  Forum HomeForum Home