private static void AddTableDescription(T context, System.Type entityType, string tableName) { string memberDescription = DescriptionInitializer <T> .GetMemberDescription(entityType); if (!string.IsNullOrEmpty(memberDescription)) { Database arg_35_0 = context.Database; string arg_35_1 = "IF EXISTS(SELECT 1 FROM syscolumns WHERE id = OBJECT_ID({1})) BEGIN IF EXISTS(SELECT 1 FROM ::fn_listextendedproperty (default,'schema',N'dbo', 'table', {1}, {2}, {3}) where name='MS_DESCRIPTION') BEGIN EXEC sp_updateextendedproperty N'MS_Description', {0}, 'SCHEMA', N'dbo', 'TABLE', {1}, {2}, {3} END ELSE BEGIN EXEC sp_addextendedproperty N'MS_Description', {0}, 'SCHEMA', N'dbo', 'TABLE', {1}, {2}, {3} END END"; object[] array = new object[4]; array[0] = memberDescription; array[1] = tableName; arg_35_0.ExecuteSqlCommand(arg_35_1, array); } }
private static void AddColumnDescription(T context, System.Reflection.PropertyInfo property, string tableName) { string text = DescriptionInitializer <T> .GetMemberDescription(property) ?? DescriptionInitializer <T> .GetDisplayName(property); if (!string.IsNullOrEmpty(text)) { context.Database.ExecuteSqlCommand("IF EXISTS(SELECT 1 FROM syscolumns WHERE id = OBJECT_ID({1}) AND NAME = {3}) BEGIN IF EXISTS(SELECT 1 FROM ::fn_listextendedproperty (default,'schema',N'dbo', 'table', {1}, {2}, {3}) where name='MS_DESCRIPTION') BEGIN EXEC sp_updateextendedproperty N'MS_Description', {0}, 'SCHEMA', N'dbo', 'TABLE', {1}, {2}, {3} END ELSE BEGIN EXEC sp_addextendedproperty N'MS_Description', {0}, 'SCHEMA', N'dbo', 'TABLE', {1}, {2}, {3} END END", new object[] { text, tableName, "COLUMN", DescriptionInitializer <T> .GetRealColumnName(property) }); } }