troubleshooting Question

.NET Enums [Flags] & Bitwise Design Question

Avatar of infotechelg
infotechelgFlag for United States of America asked on
Microsoft SQL Server.NET ProgrammingC#
6 Comments1 Solution221 ViewsLast Modified:
A hypothetical situation:

I have product features. These features are stored as BITWISE values in the database.

In my back-end code, I have a [Flags] enumerator that lists out all the features with its bitwise value assigned to each item in the enumerator.

This, obviously, gives us great benefit from a coding perspective, and, not to mention, faster I/O and fewer database records.

However, now I want to give someone the ability through a CMS interface, to add a new feature to the features table. Let's call it "Feature7"

So, "Feature7" gets added to the table with the next bit value assigned to it in the database. This is the 7th feature, so this will have a bit value of 64.

But now, the problem is that the [Flags] enum has to be manually updated to include the new feature and its new bit value. Which, doesn't really make the management of Features from CMS "automated"; there's still manual intervention needed from the developers.

So, my question is, using BITWISE, is there a way to make this fully automated without having to have code that generates a new DLL every time features are added to the table, like is suggested here:

Let me know if that makes sense.

Obviously, I know this doesn't need to be done using bits, so I don't need suggestions in that regard.

Thanks in advance!

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros