tags:

views:

23

answers:

1

Hello

I have a strongly typed dataset, i must return some scalar values : the sum of values of column, the count of records with a specified column value and so on.

I' have added some custom queries to the dataset of the kind : select sum(mycolumn) as itsname from thetable [where anothercolumn = :myparameter] (last part is optional and i'm using oracle).

I've found that some queries return generics (i.e decimal? ) while other return object. I haven't found a rule for it, some get parameters others don't.

Does anybody knows why i get this different behaviour ? Now i'm handling every query as if it where returning object, but i'd like to know if i'm doing somenthig wrong or what's the reason of this annoying behaviour

A: 

The type of value that is computed in database query will depend upon the database (it will decide that based upon type of operands and operation). For example, if the database computes the result as say currency then corresponding .NET value will be Decimal and so on. You can use database casting/type conversion operation in the query itself to ensure particular return type for the expression.

VinayC
thank you for your answer, but i don't agree its related to database . Suppose i have the following scenario : calculate the sum of expenses made by all employee, do the same calculation before, after or between specifed date. Suppose each of this functions has its own query, which is a different method of the table adapter. The dataset returns a decimal? for some of them and an object for others : why ?
Stefano