Executing a SQL script stored as a resource

后端 未结 4 967
庸人自扰
庸人自扰 2020-12-10 11:38

I would like to store lengthy .sql scripts in my solution and execute them programmatically. I\'ve already figured out how to execute a string containing my sql script but I

4条回答
  •  感动是毒
    2020-12-10 11:55

    Add the SQL files to your project then create a new resource file. Open up the SQL file and select 'Files' from the top-left drop down (default is Strings). Then hit add resource and navigate to/select the SQL file. This allows you to get SQL from the resource file without losing your type-safety like so:

    SqlFiles.SqlScript

    The above is the process in Visual Studio 2010. I also wrote about this on my blog.

提交回复
热议问题