For Nulls check out http://nullabletypes.sourceforge.net/
Regards,
William D. Bartholomew http://blog.bartholomew.id.au/
Zecharya, Bar (FIRM) wrote:
I have a webservice method that returns the results of an SQL query, and I want to encapsulate the SQL parameter values in a struct, like so:
struct ClientQueryParams { public string Lastname; public string Firstname; public int NumberOfOrders; }
In a separate ASP.NET application the user can choose more than one parameter: say the query is for "client", the user can input search values for lastname, firstname etc. The SQL is something like:
SELECT * FROM Clients WHERE (@lastname IS NULL OR [EMAIL PROTECTED]) AND (@firstname IS NULL OR [EMAIL PROTECTED])
The web app sets the struct's property to null, and the webservice sets the SQL parameter values to DBNull.Value if the struct's property is null, or the property's value if it's not null.
* Problem 1: Passing a null value * The problem is when the struct's property is a value type such as Int32, that can't be null. How to distinguish between when the user queries for all clients with no orders and when the client isn't interested in the number of orders, because the default value of an int is 0?
* Problem 2: referencing the same type in two ASP.NET apps * I've tried using the type "DBInt", only to run into a compiler error where the calling app sets the struct's properties before sending it to the web service.
myStruct.NumberOfOrders = 1; "Cannot implicitly convert 'int' to 'webServiceNamespace.DBInt'" or DBInt numOrders = 1; // this works - there is an implicit conversion! myStruct.NumberOfOrder = numOrders; // "Cannot implicitly convert 'clientNamespace.DBInt' to 'webServiceNamespace.DBInt'
Even if I put class that defines DBInt in a separate .dll, referenced in both projects, I get the same error: apparently the web reference created by VS.NET adds the webservice's namespace even though the same .dll is referenced in the calling app too.
Basically, I'm looking for either another way to encapsulate and pass SQL parameters (which could be null) to a web service, or a way to resolve this compiler error.
Thanks, Bar
=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
--- avast! Antivirus: Inbound message clean. Virus Database (VPS): 0427-0, 29/06/2004 Tested on: 30/06/2004 11:20:24 PM avast! - copyright (c) 2000-2004 ALWIL Software. http://www.avast.com
--- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0427-0, 29/06/2004 Tested on: 2/07/2004 3:04:02 PM avast! - copyright (c) 2000-2004 ALWIL Software. http://www.avast.com
=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
