I know this isn't going to help you today but I can't help thinking "ooh ooh nullable types in whidbey..." (for the first problem)...
Julie Lerman -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Zecharya, Bar (FIRM) Sent: Wednesday, June 30, 2004 9:18 AM To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] structs, namespaces, webservices and DBNull 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 =================================== 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
