Open GoogleCodeExporter opened 9 years ago
Firstly note that this is erronious if you happen to be using MySQL for you're
DB
server as MySQL supports enums in the database and in post
http://code.google.com/p/subsonicproject/issues/detail?id=79 I mention that I've
already built this functionality - so this is really just for the other DBs
like MSSQL
While I looked at initally building the enums from as simple a solution as RC
had IE:
two tables ( tbNumberOfWheels , tbColor ) and each will be translated into an
enum
and reading relationships to build the enum datatype and then writing back the
appriopriate values
I quickly realised this would fail for people like me who use multi purpose
tables IE
one table defined something like ( ID, NAME, TYPE ) values similar to ( 1 ,
'blue' ,
'colour' ) , ( 2 , 'red' , 'colour' ) , ( 3 , 'two weehls' , 'numberOfWheels' )
So I've come up with a more usable solution which requires two additional tables
Table1 ( defines the enum )
Columns being :
Name , Table, ValueColumn (Value to save ) , DisplayColumn (enum display) ,
RestrictionColumn , RestrictionValue ( values usable in an in statement : IE '
1,2,5' )
so for the above multi purpose table I would have two records / rows
( 'Colour' , 'categories' , 'ID' , 'NAME' , 'TYPE' , '"colour"' ) , (
'NumberOfWheels' , 'categories' , 'ID' , 'NAME' , 'TYPE' , '"numberOfWheels"' )
but could also be defines as ( 'Colour' , 'categories' , 'ID' , 'NAME' , 'TYPE'
,
'"lightColour","darkColour"' ) which would make an enum using both dark and
light
colours from the categories table
Table2 ( specifies when a defined enum is used )
Columns being :
Table , Column , Enum ( the ID value of the corrosponding enum from Table1 )
so i might have values like
( 'Vehiclles' 'numberOfWheels' , 2 ) - defines that the 'numberOfWheels' column
of
the Table 'Vehicles' is to use the second enum which happens to be defined
above as
NumberOfWheels
or
( 'Clothing' 'Colour' , 1 ) - defines that the 'Colour' column of the Table
'Clothing' is to use the first enum which happens to be defined above as Colour
I do plan that the table names and maybe columns as define above can be set in
the
config section for SubSonic so it's not a fixed table name and fixed column
names ,
but that would come after it works.
As I mentioned above this is erronious if you happen to be using MySQL for
you're DB
server as MySQL supports enums in the database and in post
http://code.google.com/p/subsonicproject/issues/detail?id=79 I mention that I've
already built this functionality - so this is really just for the other DBs
like MSSQL
Some comments and feedback would be great.
Original comment by cdmdotn...@gmail.com
on 30 Apr 2009 at 8:47
I would like to use the same functionality too ... Wander if it has been
implemented
already ...
Original comment by yordan.g...@gmail.com
on 23 Jun 2009 at 12:08
Actually I created already one, which is not however based on subsonic. It
works so
that a command line executable retrieves the config values from web.config file
of
the web project (gets the file path from command line ) pointing it to the db
table
( sql server 2008 - ):
CREATE TABLE [dbo].[EnumGenerator](
[EnumGeneratorId] [int] IDENTITY(1,1) NOT NULL,
[EnumName] [varchar](50) NOT NULL,
[ColNameInt] [varchar](50) NOT NULL,
[ColNameVal] [varchar](50) NOT NULL,
[TableName] [varchar](50) NOT NULL,
[ColWhereMeta] [varchar](50) NOT NULL,
[ColWhereVal] [varchar](50) NOT NULL,
[StrSqlCommand] [varchar](200) NULL,
[AssemblyName] [varchar](50) NOT NULL,
[AssemblyDirPath] [varchar](300) NOT NULL,
[TargetPath] [varchar](max) NULL,
CONSTRAINT [PK_EnumGenerator] PRIMARY KEY CLUSTERED
(
[EnumGeneratorId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
than it just generates the dll's and copies them to the bin folder of the web
project.
Here is the Web.Configs: stuff:
<appSettings>
<add key="ConnectionStringTemplate" value="Data Source={0:G};Initial
Catalog={1:G};Persist Security Info=False;User ID={2:G};Password=
{3:G};MultipleActiveResultSets=True"/>
<add key="GenAppConnectionString" value="Data
Source=hostName;initial catalog=OCMS_DEV;User
ID=OCMS_DEV_usrOcms;Password=1a1dc91c907325c69271ddf0c944bc72;persist security
info=False;"/>
<!-- the default database we are going to access-->
<add key="DefaultDb" value="ocms_dev"/>
<!-- the hosts name and instance as used in the connection string
for accessing the db-->
<add key="DbHostNameAndInstance" value="hostName"/>
<add key="DefaultLoginName" value="ocms_dev_usr"/>
<add key="DefaultLoginPass" value="pass"/>
<!-- the type of RDBMS we are going to utilize-->
<add key="DefaultRDBMS" value="SqlServer2008"/>
</appSettings>
If something does not work (needs to be reconfigured because of the environment
...
drop me e-mail ...) Feel free to delete this attachment if it does not server
the
purposes of this project ...
Original comment by yordan.g...@gmail.com
on 26 Jun 2009 at 11:37
Attachments:
Original issue reported on code.google.com by
cdmdotn...@gmail.com
on 30 Apr 2009 at 8:16