473,378 Members | 1,156 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Name conflict due to generic types and nested classes in web services[long]

Hi,

I have a simple 2-tiers (client+database) application with simple
Domain Model objects The Data Access Layer is abstracted via Data
Mappers which use Data Transfer Objects to communicate with the Domain
Model objects. My Domain Model objects are declared this way :

public class City /* Inheritance removed for brevity...*/
{
private string _Name;
private string _ZipCode;

public struct DataTransferObject
{
public string Name;
public string ZipCode;
}

/*
Constructors, methods, properties removed for brevity...
*/
}

I have a generic class DomainModelDto<TDtocontains the actual data
that is transfered between layers via
DomainModelDto<City.DataTransferObject>.

Everything is fine so far. The problem occurs when we try to create a
3-tiers (client+web services+database) application. We just want to
create new Data Mappers that will communicate to Web Services, instead
of a database. The Web Services will use the previous Data Mappers to
communicate with the database. Lot of code reuse : great !
So I create web services functions such as

[WebMethod]
public DomainModelDto<City.DataTransferObjectCityFindAll( )
{ /* ... */ }

That will work until I had another function based on another Domain
Model object (say Contact) :

[WebMethod]
public DomainModelDto<Contact.DataTransferObjectContactFi ndAll()
{ /* ... */ }

As both DomainModelDto<City.DataTransferObjectand
DomainModelDto<Contact.DataTransferObjectare serialized with the name
"DomainModelDtoOfDataTransferObject", they conflict and the web project
will not compile.

So far, the only solution I have found to this problem is to rename the
DataTransferObject structures so that they have unique names. But I
would be much more satisfied with another solution.

I have tried :
* Add [return: XmlRoot("....")] attributes to the web services methods,
but that will not change anything.
* Add [XmlRoot("...")] and [SoapType(...)] attributes to the nested
DataTransferObject classes : wasted time.
* Have DomainModelDto implement IXmlSerializable, and specifiy the
XmlSchemaProvider attribute. But then, if I know how to serialize my
generic Dto (City for instance) with a XmlSerializer, I do not know how
to get the schema for the type (the only way I have found is to use
xsd.exe, which is ... not a way !).

Thanks for reading this far, any help appreciated.

Mathieu
Aug 30 '06 #1
0 767

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
17
by: Andreas Huber | last post by:
What follows is a discussion of my experience with .NET generics & the ..NET framework (as implemented in the Visual Studio 2005 Beta 1), which leads to questions as to why certain things are the...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
0
by: Mathieu Cartoixa | last post by:
Hi, I have a simple 2-tiers (client+database) application with simple Domain Model objects The Data Access Layer is abstracted via Data Mappers which use Data Transfer Objects to communicate...
21
by: Charles Sullivan | last post by:
I maintain/enhance some inherited FOSS software in C which has compiler options for quite a few different Unix-like operating systems, many of which I've never even heard of. It would be...
6
by: karthikbalaguru | last post by:
Hi, I find that the program gives the offset of the member of the structure. So, probably similar to offsetof() . But, This is the first time i am seeing the typecast with ' 0' . What does...
28
by: Peter Oliphant | last post by:
I have written a program using MS VS VC++ 2005 Express, /cli pure. Upon compiling it it works fine in the GUI development environment. It also works fine as a Debug stand-alone. ut I had an odd...
11
by: Bob Altman | last post by:
Hi all, I want to write a generic class that does this: Public Class X (Of T) Public Sub Method(param As T) dim x as T = param >3 End Sub End Class
9
by: Meendar | last post by:
Hi, Below is my code snippet having only one form, <form> <input type ="radio" name="action" value="xyz" checked>xyz <input type ="radio" name="action" value="zyx">zyx <input type ="radio"...
4
by: reach2raziq | last post by:
Hi I have one web application that used as posting messages like blogs... message contented are displayed inside div tag. problem- when user types long word without any space the div gets...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.