468,268 Members | 1,703 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

Accessing Class Properties

When designing a DAL (data access layer), I designed the methods to
return custom classes that contain properties. Example:

public class Employee
{
private string _name;

public string Name
{
get { return _name; }
}

public Employee()
{
_name = "Employee Name";
}
}

[...]

public static Employee GetEmployee()
{
return new Employee();
}

The requirements have since changed completely from what they were
originally and I'll have to design the DAL as a web service. I didn't
think this would be a big deal, but apparently properties are not
serialized as XML as I had expected.

There is quite a bit of custom code developed in the DAL, so I'm
obviously looking for the simplest approach to modifying my original
code into something that can be accessed through a web service.

Does anybody have any suggestions on how to implement this design change
as seamless as possible?

Thank you in advance,

--
Sean
Dec 14 '06 #1
4 1109
How about implementing webmethods that get/set internal class property
values?
"senfo" <en**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
When designing a DAL (data access layer), I designed the methods to return
custom classes that contain properties. Example:

public class Employee
{
private string _name;

public string Name
{
get { return _name; }
}

public Employee()
{
_name = "Employee Name";
}
}

[...]

public static Employee GetEmployee()
{
return new Employee();
}

The requirements have since changed completely from what they were
originally and I'll have to design the DAL as a web service. I didn't
think this would be a big deal, but apparently properties are not
serialized as XML as I had expected.

There is quite a bit of custom code developed in the DAL, so I'm obviously
looking for the simplest approach to modifying my original code into
something that can be accessed through a web service.

Does anybody have any suggestions on how to implement this design change
as seamless as possible?

Thank you in advance,

--
Sean

Dec 14 '06 #2
Scott M. wrote:
How about implementing webmethods that get/set internal class property
values?
I have nothing against this idea, per sey; I'm just trying to avoid
having to rewrite quite a bit of custom code, if that's possible. If
there are no other alternatives, I'll just have to do it.

Thank you for the response,

--
Sean
Dec 14 '06 #3
Scott M. wrote:
How about implementing webmethods that get/set internal class property
values?
The thing that doesn't make sense to me is that it's possible to, for
example, return a DataSet object from a WebMethod. The DataSet object
is useless without its properties, so how does .NET manage to
successfully serialize a DataSet object for use on .NET clients, whereas
the class I wrote is not?

Thank you again,

--
Sean
Dec 14 '06 #4
A WebService class itself doesn't expose properties over the web (as you
found out), but you can certainly create your own serializable class that
can be returned from a WebService. Once the consumer recieves and
de-serailizes it, the consumer would be able to access the properties.
BUT - - you must make the class serializable yourself correctly to ensure
that the properties will serialize/deserialize correctly.

It's the difference between calling a WebService class and returning a
serialized class (not the same thing).
"senfo" <en**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
Scott M. wrote:
>How about implementing webmethods that get/set internal class property
values?

The thing that doesn't make sense to me is that it's possible to, for
example, return a DataSet object from a WebMethod. The DataSet object is
useless without its properties, so how does .NET manage to successfully
serialize a DataSet object for use on .NET clients, whereas the class I
wrote is not?

Thank you again,

--
Sean

Dec 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by joealey2003 | last post: by
1 post views Thread by Jason Bell | last post: by
6 posts views Thread by DKode | last post: by
5 posts views Thread by Cyril Gupta | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.