Using DB field description as XML comment

Posts   
 
    
fdb
User
Posts: 43
Joined: 01-Jul-2008
# Posted on: 16-May-2009 07:23:39   

Hi, I'm using LLBLGen v2.6, Adapter mode, LINQ and .NET 3.5.

Is it possible to configure LLBLGen to use DB field description as XML comment for the generated entity classes?

Regards, Farzad Badili

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 16-May-2009 11:48:23   

Yes this feature is called custom properties and you can obtain them from the DB when you refresh or create a project (check the checkbox on the form at the bottom). Please check the preferences and project properties section in the manual for details about settings in this area, as by default this is disabled to avoid people importing large blocks of crap-text inserted into extended properties / descriptions by MS database tooling.

Frans Bouma | Lead developer LLBLGen Pro
tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 28-Jul-2009 20:40:04   

I can't seem to get this working on my existing project. I'm using LLBLGen 2.6, 6/6/08 designer, and SQL Server 2008.

In Properties, I've set RetrieveDBCustomProperties to True. Then I refresh my project, and ensure Custom Properties is checked. The description fields from my tables are still not brought into the project.

How can I get this working?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 28-Jul-2009 22:39:43   

This only works for entities added to the project after the options have been set and the database refreshed - it will not update the existing entities in the project.

You can remove and immediatly add your entites to the project for the properties to be picked up.

Matt

tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 28-Jul-2009 23:31:28   

I removed and re-added the entity, (after ensuring the properties were set and a refresh performed), yet the Table Description from SQL Server still didn't make it into Custom Properties for the Entity.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Jul-2009 09:22:44   

Just to make sure, did you set the RetrieveDBCustomProperties property in the Project Properties or in the User Preferences?

tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 29-Jul-2009 09:53:13   

In both Properties and Preferences it is set to True

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Jul-2009 10:12:08   

LLBLGen 2.6, 6/6/08 designer

Just to rule this probability out, would you please use the latest version of LLBLGen Pro Designer.

tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 29-Jul-2009 11:07:18   

Upgraded to 7/9/09 designer, same results

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jul-2009 17:49:26   

Let's get the elements sorted you have done. - did you check the checkbox in the refresh dialog to obtain the custom properties? - In catalog explorer, if you go to the table and view it in details view, you can right-click the table (or fields) and view the custom properties. Are the custom properties there?

Frans Bouma | Lead developer LLBLGen Pro
tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 29-Jul-2009 18:38:55   

The box for custom properties is checked, yes. In catalog explorer, under the column # of custom column, 0 is listed, for both when the Table itself is selected, or all the fields. (I have descriptions on both in SQL Server)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jul-2009 20:17:07   

Then they're not read from the schema apparently. Could you please post the DDL SQL as produced by sqlserver management studio (CREATE TABLE statement) ? We can then try to create that exact table here in our 2008 install and check what the problem is.

Frans Bouma | Lead developer LLBLGen Pro
tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 29-Jul-2009 21:29:12   

Attached, you'll need to erase the Relationship (constraint) statements at the end of the script...wanted to give you the entire DDL.

Attachments
Filename File size Added on Approval
LLBLGen_TestScript.sql 2,743 29-Jul-2009 21:29.26 Approved
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Jul-2009 07:35:59   

I couldn't reproduce it, following is what I did.

1- I used an existing project and an existing database. 2- I ran the DDL script you gave against my database (I removed the FK references because no such tables exist in my schema). 3- I opened the lgp project and went to Project->Properties menu item. 4- I set both UpdateCustomPropertiesAfterRefresh and RetrieveDBCustomProperties to true. 5- Clicked on the Catalog and selected Refresh. 6- Now I see the Custom Properties checkbox checked, in the Catalog Refresh Dialog. 7- After doing refresh I added the new Activity entity to my mapped Entities tree. 8- Going to it's properties I can see fields descriptions as custom properties. 9- I went and generated the code. 10- And the following is some code snippets of what has been generated in the ActivityEntity class:

private static void SetupCustomPropertyHashtables()
        {
            _customProperties = new Dictionary<string, string>();
            _fieldsCustomProperties = new Dictionary<string, Dictionary<string, string>>();
            _customProperties.Add("MS_Description", @"Indicates that all or some of the monetary value of the Activity is for a specific Purpose and ActivityType.");
            Dictionary<string, string> fieldHashtable = null;
            fieldHashtable = new Dictionary<string, string>();
            fieldHashtable.Add("MS_Description", @"Link to Activity table");
            _fieldsCustomProperties.Add("ActivityId", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();
            fieldHashtable.Add("MS_Description", @"The fractional amount of the parent Activity that is for support.");
            _fieldsCustomProperties.Add("Value", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("PurposeCodeId", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("Noted", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("Description", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();
            fieldHashtable.Add("MS_Description", @"Date Activity took place");
            _fieldsCustomProperties.Add("Date", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("ContactId", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("ClientAccountId", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("TransId", fieldHashtable);
            fieldHashtable = new Dictionary<string, string>();

            _fieldsCustomProperties.Add("ParentId", fieldHashtable);
        }
        /// <summary> The ActivityId property of the Entity Activity<br/><br/>
        /// 
        /// MS_Description: Link to Activity table<br/></summary>
        /// <remarks>Mapped on  table field: "Activity"."ActivityID"<br/>
        /// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
        /// Table field behavior characteristics (is nullable, is PK, is identity): false, true, true</remarks>
        public virtual System.Int32 ActivityId
        {
            get { return (System.Int32)GetValue((int)ActivityFieldIndex.ActivityId, true); }
            set { SetValue((int)ActivityFieldIndex.ActivityId, value); }
        }
tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 30-Jul-2009 20:21:18   

I followed these steps with no luck. Which version of SQL Server are you using? I have 10.0.1600

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Jul-2009 10:06:34   

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86) Mar 29 2009 10:27:29 Copyright (c) 1988-2008 Microsoft Corporation Express Edition with Advanced Services on Windows NT 6.0 <X86> (Build 6001: Service Pack 1)

tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 31-Jul-2009 10:29:27   

I'm running Enterprise, I'll put the Service Pack on tomorrow and see what happens. I also tried it with a brand new project and no luck. Are there settings on SQL Server that have to be enabled?

tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 31-Jul-2009 10:47:55   

My apologies, turns out I had outdated LLBLGen database drivers, from July 2008. Thanks for the help.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Jul-2009 10:50:28   

No problem. Good luck.