Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to put Calculated Fields
Message
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Titre:
Where to put Calculated Fields
Versions des environnements
Environment:
C# 2.0
Database:
MS SQL Server
Divers
Thread ID:
01091608
Message ID:
01091608
Vues:
52
Hi all,

I have a table that has a tinyint field (nDayOfWeek). I use bits 1 - 7 to correspond to the days of the week. This way I can (in one byte) store any combination of days. I'm creating a typed dataset tableAdapter class around this table (using stored procs for data access). How should I go about creating these calcultated fields?
Option 1:
Create 7 calculated fields in the table with formula like:
CASE WHEN nDayOfWeek & 2 = 2 THEN 1 ELSE 0 END as lMonday
CASE WHEN nDayOfWeek & 4 = 4 THEN 1 ELSE 0 END as lTuesday
...
Option 2:
Create those 7 fields in the Stored Procedure that gets the data.
Option 3:
Create 7 properties on my class in C# that translates the appropriate bit from the real field for the 7 "fake" ones.
Something else???
If Option 3, do I add the properties to the DataRow or multiple places or where?

TIA,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform