Problem moving code from LINQPad to VS project
I'm having a bit of a problem.
I have a LINQPad C# script that does this:
var allProcs = (from routine in theDatabaseContext.INFORMATION_SCHEMA.ROUTINES
where routine.ROUTINE_TYPE == "PROCEDURE" ||
routine.ROUTINE_TYPE == "FUNCTION"
select new {
Name = routine.ROUTINE_NAME.ToUpper(),
Type = "Proc/Func",
Text = routine.ROUTINE_DEFINITION.ToUpper()
}).ToList();
Works great in LINQPad. But getting this into a VS project is problematic. You can't add INFORMATION_SCHEMA to a DBML designer in Visual Studio. I've seen workarounds on the web where people create temporary tables that are basically dumps of what's in this view, but I do not have the appropriate rights to modify schema/create tables. But obviously LINQPad is capable of generating a good db context to the system view here. How can I get the functionality above into my VS script without re-writing my script (there are other queries similar to this in the script).
Thanks,
Randy
I have a LINQPad C# script that does this:
var allProcs = (from routine in theDatabaseContext.INFORMATION_SCHEMA.ROUTINES
where routine.ROUTINE_TYPE == "PROCEDURE" ||
routine.ROUTINE_TYPE == "FUNCTION"
select new {
Name = routine.ROUTINE_NAME.ToUpper(),
Type = "Proc/Func",
Text = routine.ROUTINE_DEFINITION.ToUpper()
}).ToList();
Works great in LINQPad. But getting this into a VS project is problematic. You can't add INFORMATION_SCHEMA to a DBML designer in Visual Studio. I've seen workarounds on the web where people create temporary tables that are basically dumps of what's in this view, but I do not have the appropriate rights to modify schema/create tables. But obviously LINQPad is capable of generating a good db context to the system view here. How can I get the functionality above into my VS script without re-writing my script (there are other queries similar to this in the script).
Thanks,
Randy
Comments
-
Check out the thread at http://forums.oreilly.com/topic/20228-linqpad-better-than-sql-metal/
Even if you don't want to use the full linqpad dll, it might be possible to decompile and extract just the class for INFORMATION_SCHEMA.ROUTINES and add this to your vs project.