When developing, it is not necessary to use SQL to directly interact with the database, when the table names and field names in the database are used more. If you copy one every time you use it, the egg hurts.
So consider making it a const constant. But there are quite a few tables and fields in the database, one knocking, not only tired, but also possibly knocking the wrong. The best way to ensure that you are right is to use tools or scripts, of course.
A SQL script implementation is provided here.
Principle: Get the table---of the database > traverse the fields in each table---> Generate data
SQL code
DECLARE @tableName varchar (max) DECLARE @tableCount intdeclare @tableIndex intdeclare @tempTable TABLE (DATA VARCHAR (max) ) SELECT @tableCount =count (*) from SysObjects WHERE xtype= ' u '--xtype= ' u ': represents all user tables; --xtype= ' S ': denotes all system tables; SET @tableIndex =1while @tableIndex <[email protected]beginselect @tableName =name from (SELECT row_number () over ( ORDER by NAME) as Tempno,name from SysObjects WHERE xtype= ' U ') tempwhere [e-mail Protected]insert into @tempTable VALUES (' INSERT into @tempTable values (' #region ' [e-mail protected]) insert into @tempTable values ("Public sealed class" [Email PR otected]+ ' {') INSERT into @tempTable SELECT ' public const string ' +name+ ' = "' +name+ '"; ' From syscolumns where ID in (SELECT ID from sysobjects WHERE [e-mail protected]) INSERT into @tempTable VAL UES ('} ') insert into @tempTable values (' #endregion ') insert into @tempTable values (") SET @tableIndex +=1endselect * from @ TempTable
Results of the Build
result graphs in SQL
Result graphs in C #
Specific adjustments can be made as needed