B
Bennett Haselton
One of the most convenient features of Visual Studio .Net and ASP.Net
is being able to add rows to a SQL Server database in an
intellisense-safe way, with code like:
newRow.Setparent_post_idNull();
newRow.post_text = this.lblMessageBody.Text;
newRow.post_datetime = System.DateTime.Now;
dsLocalDataSet1.user_post.Adduser_postRow(newRow);
this.oleDbUserPostAdapter.Update(dsLocalDataSet1.user_post);
If I want my "row" objects to contain an enumerated type and to still
be stored in the SQL Server database table, is there a seamless way to
do that without sacrificing all the benefits of typed datasets and the
code they automatically generate as in the examples above?
If I can't do it with true enums (called, for example,
PostStatus.AwaitingResponse and PostStatus.HasBeenRepliedTo), then I
could have a PostStatus class with public static constant strings
PostStatus.AwaitingResponse, whose value is "AwaitingResponse", and
PostStatus.HasBeenRepliedTo, whose value is "HasBeenRepliedTo", and
then have the type of that data field simply be a string when stored
to the database, and then when reading from the database, compare the
string value to PostStatus.AwaitingResponse or to
PostStatus.HasBeenRepliedTo to see what it is. (Storing them as ints
would make sorting and other operations faster, but storing them as
strings would make it easier to see what the actual values are when
viewing the database table directly.) Just wondering what the pros
usually do in this case!
-Bennett
is being able to add rows to a SQL Server database in an
intellisense-safe way, with code like:
newRow.Setparent_post_idNull();
newRow.post_text = this.lblMessageBody.Text;
newRow.post_datetime = System.DateTime.Now;
dsLocalDataSet1.user_post.Adduser_postRow(newRow);
this.oleDbUserPostAdapter.Update(dsLocalDataSet1.user_post);
If I want my "row" objects to contain an enumerated type and to still
be stored in the SQL Server database table, is there a seamless way to
do that without sacrificing all the benefits of typed datasets and the
code they automatically generate as in the examples above?
If I can't do it with true enums (called, for example,
PostStatus.AwaitingResponse and PostStatus.HasBeenRepliedTo), then I
could have a PostStatus class with public static constant strings
PostStatus.AwaitingResponse, whose value is "AwaitingResponse", and
PostStatus.HasBeenRepliedTo, whose value is "HasBeenRepliedTo", and
then have the type of that data field simply be a string when stored
to the database, and then when reading from the database, compare the
string value to PostStatus.AwaitingResponse or to
PostStatus.HasBeenRepliedTo to see what it is. (Storing them as ints
would make sorting and other operations faster, but storing them as
strings would make it easier to see what the actual values are when
viewing the database table directly.) Just wondering what the pros
usually do in this case!
-Bennett