简体   繁体   English

F# SqlDataConnection 类型提供程序 - 运行一次,而不是每次编译

[英]F# SqlDataConnection Type Provider - Run once, instead of on every compile

Is there a good example or explanation of how to crawl you Development version of your database once with the SqlDataConnection type provider declaration, but not run it on every compile?是否有一个很好的示例或解释,说明如何使用 SqlDataConnection 类型提供程序声明一次抓取您的数据库的开发版本,但不是在每次编译时都运行它? And what is the correct way to specify the connection as a string parameter instead of string literal?将连接指定为字符串参数而不是字符串文字的正确方法是什么?

How to avoid hitting the DB on every compile如何避免在每次编译时击中数据库

Use the LocalSchemaFile static parameter with ForceUpdate = false .使用带有ForceUpdate = falseLocalSchemaFile静态参数。 See this answer for more info.有关更多信息,请参阅此答案

How to avoid using a string literal for the connection string如何避免对连接字符串使用字符串文字

Two options:两种选择:

  • Put your connection string in app.config and use ConnectionStringName to point to it.将您的连接字符串放在app.config并使用ConnectionStringName指向它。

  • Use local schema file for compile-time, then pass an arbitrary connection string at runtime.编译时使用本地模式文件,然后在运行时传递任意连接字符串。

     type NorthwndDb = SqlDataConnection<ForceUpdate=false, LocalSchemaFile="schema.dbml"> let db = NorthwndDb.GetDataContext(realConnectionStringHere)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM