473,570 Members | 2,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generated classes based on MSSQL

Disclaimer: This could be considered an ADO question, but, it really is a
question of code maintenance.

I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
value int
The following Class would be generated:
'--------------------8<---------------------------------
Class ITEM
Public Structure Fields
Public Const item_id as String = "item_id"
Public Const description as String = "descriptio n"
Public Const value as String = "value"
End Structure

Function item_id(dbo as DataRow) as System.String
Return CastDB.ToString (dbo, Fields.item_id)
End Function

Function description(dbo as DataRow) as System.String
Return CastDB.ToString (dbo, Fields.descript ion)
End Function

Function value(dbo as DataRow) as System.Int32
Return CastDB.ToInt32( dbo, Fields.integer)
End Function
End Class
'--------------------8<---------------------------------
So it allows you to use intellisense with your field names, and the classes
are automatically synchronized when if the database changes once it is
setup. The biggest advantage is that when a field (or other object)
changes, everything that uses that object in your app now throws a compile
error.

So I guess my question is this: what are the possible negative issues with
doing this?
Pros:
- allows intellisense with fields, tables, views and stored procedures
- simplifies database-to-code maintenance (shows errors when names change)
- provides easy access to field values
- requires less trips back to Query Analyzer to check data types etc...

Cons:
- complicates maintenance

TIA

~
Jeremy

Nov 20 '05 #1
2 1254
In article <U2************ *********@twist er.tampabay.rr. com>,
jeremy.cowles[nosp@m]asifl.com says...
Disclaimer: This could be considered an ADO question, but, it really is a
question of code maintenance.

I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
value int
The following Class would be generated:
'--------------------8<---------------------------------
Class ITEM
Public Structure Fields
Public Const item_id as String = "item_id"
Public Const description as String = "descriptio n"
Public Const value as String = "value"
End Structure

Function item_id(dbo as DataRow) as System.String
Return CastDB.ToString (dbo, Fields.item_id)
End Function

Function description(dbo as DataRow) as System.String
Return CastDB.ToString (dbo, Fields.descript ion)
End Function

Function value(dbo as DataRow) as System.Int32
Return CastDB.ToInt32( dbo, Fields.integer)
End Function
End Class
'--------------------8<---------------------------------
So it allows you to use intellisense with your field names, and the classes
are automatically synchronized when if the database changes once it is
setup. The biggest advantage is that when a field (or other object)
changes, everything that uses that object in your app now throws a compile
error.


Sounds very similar to a typed dataset, which VS.NET can generate for
you automatically:

http://support.microsoft.com/default...b;EN-US;315678

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2
Nice! I remeber reading something about that back duing the VS.NET media
frenzy. I guess I need to get a good book on ADO.NET, this is really cool.
It's not exactly how my solution works, but I think using the built-in
facilities would be much better for maintainence down the road.

Thanks,
Jeremy
"Patrick Steele [MVP]" <pa*****@mvps.o rg> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
In article <U2************ *********@twist er.tampabay.rr. com>,
jeremy.cowles[nosp@m]asifl.com says...
Disclaimer: This could be considered an ADO question, but, it really is a question of code maintenance.

I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
value int
The following Class would be generated:
'--------------------8<---------------------------------
Class ITEM
Public Structure Fields
Public Const item_id as String = "item_id"
Public Const description as String = "descriptio n"
Public Const value as String = "value"
End Structure

Function item_id(dbo as DataRow) as System.String
Return CastDB.ToString (dbo, Fields.item_id)
End Function

Function description(dbo as DataRow) as System.String
Return CastDB.ToString (dbo, Fields.descript ion)
End Function

Function value(dbo as DataRow) as System.Int32
Return CastDB.ToInt32( dbo, Fields.integer)
End Function
End Class
'--------------------8<---------------------------------
So it allows you to use intellisense with your field names, and the classes are automatically synchronized when if the database changes once it is
setup. The biggest advantage is that when a field (or other object)
changes, everything that uses that object in your app now throws a compile error.


Sounds very similar to a typed dataset, which VS.NET can generate for
you automatically:

http://support.microsoft.com/default...b;EN-US;315678

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele


Nov 20 '05 #3

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

Similar topics

1
417
by: Ellen K. | last post by:
First of all, I have never done any web-based stuff, so if the following sounds ignorant, it's because I am! So far all our SQL Servers are accessed only over our network and we use Windows authentication. Now the guy I'm working with on the design of our next stuff wants the two new databases (a transactional one and my data warehouse)...
12
12406
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server...
0
1584
by: vanGogh | last post by:
I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool. My goal is to: - write an application that can parse XML documents - fill objects (based on the generated classes) with the XML data in element nodes or attributes - assemble the objects so they are contained in their parent - add the resulting object to an...
2
2505
by: farseer | last post by:
Hi, First, sorry for this long post, but i'd like to explain my problem in detail... i have generated some classes from my schema. Classes are generated for the root (overall document), complexTypes with complexContents (this is how my types in the xsd are defined), and elements defined as complextypes that contain more than one unbounded...
3
5754
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three DLLs. After building it up, I've deployed it on the web server. From my Windows application, I then add a web reference to that web service.
3
1795
by: Nick Gilbert | last post by:
Hi, I have to send an array of prices for a list of products over XML. Currently my XML data looks like this: <ArrayOfProd> <Prod Code="productcode001"> <Prices> <P F="2005-01-01" T="2005-09-09" Q="10" V="27.50" />
4
1998
by: Fabio | last post by:
An ASP.NET 2.0 web site contains a web form and a web service. The web form consumes the web service. There is a Book class in the App_Code folder. The web service exposes a method that returns a Book object. The consumer includes a method that require a Book parameter. However the Book generated proxy class conflicts with the Book class in...
3
5388
by: Arpan | last post by:
Web Services make use of proxy classes whose methods & properties are accessed in exactly the same way as how a normal class' methods & properties are accessed. So what for does ASP.NET generate proxy classes (using WSDL) which consume more hard disk space & resources? For e.g. consider the following code which exists in a user-defined...
1
2456
by: Martin Z | last post by:
I'm getting acquainted with the whole XML/XSD thing, and I've run into a wall. I have a tree of objects that I deserialize from XML for configuration reasons. I have generated XSD from the classes for this tree. I have made an XML file that validates against that XSD. However, when I try to deserialize from the XML file, I get complaints...
0
7637
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...
0
7950
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. ...
0
8000
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...
1
5523
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...
0
3684
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...
0
3671
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2133
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
1
1238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.