Mark
Mark

Reputation: 11750

TSqlObject has no ContextObject property?

I'm attempting to create a T4 template that generates source code for calling stored procedures that are contained in another project in my solution. I am able to successfully enumerate the .sql files in the solution, add them to a TSqlModel, and use that model to retrieve the list of stored procedures as TSqlObject instances. Now, I need to enumerate the parameters for each stored procedure, and this is where I'm getting hung up.

When I debug my template, I can see that the TSqlObject instances have a ContextObject property, and this property contains, among other things, the list of parameters that I need to generate my code. When I attempt to access this property from my template, however, the compiler complains that the property doesn't exist:

Error 1 Compiling transformation: 'Microsoft.SqlServer.Dac.Model.TSqlObject' does not contain a definition for 'ContextObject' and no extension method 'ContextObject' accepting a first argument of type 'Microsoft.SqlServer.Dac.Model.TSqlObject' could be found (are you missing a using directive or an assembly reference?) d:\Code\cs\test_sproccodegen\CallingProject\sproc_template.tt 34 111 CallingProject

I can definitely access this ContextObject property from the Immediate window while debugging, but it is not available at compile time.

enter image description here

What am I doing wrong?

Upvotes: 1

Views: 243

Answers (2)

Kevin Cunnane
Kevin Cunnane

Reputation: 8110

That's an internal method as mentioned by Will in the question comments. You should use the public APIs instead. The following documenation should help you get started:

Upvotes: 1

user1228
user1228

Reputation:

The property isn't listed in the API, which probably means it's internal or private. Only public and protected accessible members are included in the docs.

Checking it out in JustDecompile, you can see it is, in fact, internal.

boom, internal

Upvotes: 4

Related Questions