472,102 Members | 1,062 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 = "description"
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.description)
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 1190
In article <U2*********************@twister.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 = "description"
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.description)
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.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <U2*********************@twister.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 = "description"
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.description)
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ellen K. | last post: by
12 posts views Thread by HarveyB | last post: by
2 posts views Thread by farseer | last post: by
3 posts views Thread by Nick Gilbert | last post: by
3 posts views Thread by Arpan | last post: by

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.