In my database I have tables that define types for example
Table: Publication Types
ID | Type ---------- 1 | Article 2 | Abstract 3 | Book ....
Which is related through the ID key to a publication tables which has the field TypeID.
I then create a PublicationTable data table my .NET application which I want to filter based on the publication type. For example the following function gives me the number of publications for a specific author and publication type.
Public Function countPublications(ByVal authorID As Integer, _ ByVal publicationType As Integer) As Integer Dim authPubs As New PublicationsDataSet.tblPublicationsDataTable authPubs = Me.getAuthorsPublications(authorID) Dim dv As New DataView(authPubs) dv.RowFilter = 'status='published' AND type='' + _ publicationType.ToString + ''' Return dv.Count End Function
To call this function to get a count of articles by an author of a specific type, I could
-
call the function with two integers
countPublications(authorID, 1)
-
setup an enum so that I can write
countPublications(authorID, pubType.Article)
or
-
somehow use the publication type table to filter the publication data set but I haven’t got my head around how to do this.
What other approaches should I consider.
Thanks
if publication types are essentially static, enums are fine
there is arguably little difference between embedding
in a query and adding
they’re both embedded constants, the former just has a well-defined type behind it
alternately you could use
i prefer the former
if, on the other hand, new lookup types may be added after the code is deployed, then an enum will quickly become outdated;
but if there is core set of static enum values that the code needs and the rest don’t matter then the former solution is still fine
as usual, ‘it depends’ 😉