473,938 Members | 41,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1236
How about implementing webmethods that get/set internal class property
values?
"senfo" <en**********@y ahoo.comI-WANT-NO-SPAMwrote in message
news:Om******** ******@TK2MSFTN GP04.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**********@y ahoo.comI-WANT-NO-SPAMwrote in message
news:u9******** ******@TK2MSFTN GP03.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2139
by: joealey2003 | last post by:
Hi all... I included a css file on my html and i need to check some properties. The html is: <style id="myid" src="mycsspage.css"> </style> Now i need something to access it like: alert(document.getElementById("myid").bottomline.color);
1
1612
by: Jason Bell | last post by:
Every example of properties I've seen have used simple types such as integers and strings. Here's the scenario I'm trying to work out (3D graphics programming): I have a class called Matrix16f, containing 16 floats that define the matrix, which in turn defines an object's position and orientation in 3D space. As well I want it to have a "position" property, which is a 3D vector that sets the Position values of the matrix.
6
1232
by: DKode | last post by:
Ok, kind of a silly question I just want to know what the proper method is, When I have local Properties, ie: private bool _someVal; public bool SomeVal { get { return _someVal; } }
8
2756
by: dwok | last post by:
I have been wondering this for a while now. Suppose I have a class that contains some private member variables. How should I access the variables throughout the class? Should I use properties that expose the variables or is it OK to just access the variables directly? Keep in mind that I am talking about accessing the variables from within the class that they are defined. Thanks!
5
2712
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of properties. I want to know if there is a way to access the methods and the properties of the Owner class for the class that's inside it? I.e. I want to find out within Engine what make the Car is which is exposed by the property Car.Model.
37
3614
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element. However, I can't seem to access the "hover" properties. example :
3
2825
by: Alex | last post by:
Hi all, I'm trying to create an arraylist of a user control class... I'm able to define the list and add objects (panels) to it, but I can access and of the panel properties using an index... Is there a way to do this, or do I need to copy each node into an interim handle of the correct class before manipulating it? ie,
4
2803
by: Suresh | last post by:
Is there any way to access the custom properties of a master page from the aspx form? I know the custom properties of a master page can be accessed from the aspx.cs partial class by specifying the MasterType directive on the aspx form. My master page will render a custom navigation menu and I'd like to put in the properties of which tab and sub tab to load and other misc style info in the aspx form that can be used by master page.
8
6571
by: RSH | last post by:
Hi, I have a situation where I have a Parent Object (Company) which has several public properties. The Company Object also creates an Employees object which has its ow set of functions and properties. I am trying to figure out how to access the Parent properties from the child object. Simplified example: Class Company Public ReadOnly Property Employees() As Employees
0
10131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9963
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11516
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7377
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6072
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4443
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.