Friday, February 10, 2012
Support » Support Forum
Register Login
HomeWhat is NDO?- Executive Overview- NDO for DevelopersHow NDO Works- Persistent Classes- Mapping- Queries- Reverse Engineering- Inheritance, Polymorphism- Distributed ApplicationsLicensingSupport- Support Forum- FAQ- Solutions- Downloads- E-Mail Support- Tutorial VideosOnline ShopContact
Welcome to the NDO support forum!
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. 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. The forum software requires that javascript is enabled. Please do not insert licence information or licence keys in forum posts. If you know a good answer to a post of another user, feel free to reply! The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.
Hi, I try the following in C#:
PersistenceManager pm = new PersistenceManager(); Query myQuery = pm.NewQuery(typeof(myClass)); decimal test = myQuery.ExecuteAggregate(field name as string, Query.AggregateType.Max);
I get the error message: "Die angegebene Umwandlung ist ungültig." (Invalid Cast). Then I try:
PersistenceManager pm = new PersistenceManager(); Query myQuery = pm.NewQuery(typeof(myClass)); decimal test = myQuery.ExecuteAggregate(column name as string, Query.AggregateType.Max);
Then I get the error message: "Can't find mapping information for field myClass.myField", but the mapping file is available. If I try >field name as string< and >Query.AggregateType.Count< I get the correct count value. What am I doing wrong or doesn't work NDO with MS SQL Server 2005 ? Thanks.
Hi lursa,
it seems, as if there is no record in your database. The Max aggregate function returns a DbNull value, which cannot be converted to a decimal value. Count returns 0 in this case, which is convertible to decimal - that's why Count works. So, just add a record to your database and Max should work properly. If your business logic should work even if there are no result columns in the database, make sure to fetch the Count value before you fetch the Max value and check if it is 0.
Best RegardsMirko