首页 \ 问答 \ 如何使用C#以编程方式部署数据库(How to deploy a database programatically with C#)

如何使用C#以编程方式部署数据库(How to deploy a database programatically with C#)

我的解决方案中有一个数据库项目,需求很简单(不太确定实现)。

有没有办法以编程方式部署数据库项目?

PS:我不是指附加MDF文件。 我的意思是将数据库部署到SQL Server实例。


I have a database project in my solution and the requirement is simple (not so sure about the implementation).

Is there a way to deploy the database project programatically?

PS: I don't mean attach an MDF file. I mean deploy the database to a SQL Server instance.


原文:https://stackoverflow.com/questions/10513664
更新时间:2023-02-10 20:02

最满意答案

实际上,F#3.0中观察到的编译器错误读取:

错误FS1220:ReflectedDefinitionAttribute可能不会应用于结构类型上的实例成员,因为实例成员采用隐式“this”byref参数

观察到的行为的根本原因是F#引用的限制 - 您不能在引用的代码中使用byref类型。

然而,此限制的结果仅适用于实例 struct成员; static struct成员可以使用[<ReflectedDefinition]>属性进行修饰。


In fact, the observed compiler error in F# 3.0 reads:

error FS1220: ReflectedDefinitionAttribute may not be applied to an instance member on a struct type, because the instance member takes an implicit 'this' byref parameter

The root cause of the observed behavior is the limitation of F# quotations - you cannot use byref types in the quoted code.

Nevertheless, the consequence of this limitation is applicable only to the instance struct members; static struct members can be decorated with [<ReflectedDefinition]> attribute.

相关问答

更多
  • 报价不是我的强项,但请查看其中的区别: let z = "60614" let foo = <@ List.filter (fun s -> s = z) @> printfn "%A" foo let foo2 = let z = z <@ List.filter (fun s -> s = z) @> printfn "%A" foo2 我想也许'z'是表达式的本地意味着捕获值,而不是属性引用。 Quotations are not my forte, but check o ...
  • 我没有看到struct...end语法用得多,但是直接重构看起来像这样(这种类型的名称很奇怪,见下文): type AngularSpeed = struct val Angle : float val Speed : float val Time : float end private new (angle, speed, time) = { Angle = angle; Speed = speed; Time = ...
  • 这几乎是相同解决方案策略的直接翻译。 也就是说,我认为可能有更好/更简单的代表选择,我仍在仔细考虑。 type Runner = int -> Result and Result = Result of int * option let AddOne = fun x -> Result(x+1, None) let Idle = fun x -> Result(x, None) let rec Pair(r1,r2) = fun x -> match r1 x with ...
  • 实际上,F#3.0中观察到的编译器错误读取: 错误FS1220:ReflectedDefinitionAttribute可能不会应用于结构类型上的实例成员,因为实例成员采用隐式“this”byref参数 观察到的行为的根本原因是F#引用的限制 - 您不能在引用的代码中使用byref类型。 然而,此限制的结果仅适用于实例 struct成员; static struct成员可以使用[属性进行修饰。 In fact, the observed compiler erro ...
  • 你是对的 - camlp4库不适用于F#,所以恐怕你需要使用另一种方法在F#中重新实现所需的功能。 总的来说,您可以使用F#中的一些相关技术(但很难判断它们中的任何一个对您是否有用,而不了解更多具体问题): F#语句允许您操作F#代码,但编译能力有限(即将F#翻译为SQL,JavaScript或GPU) F#CodeDom (来自F#PowerPack)允许您使用F#编译器生成代码并进行编译,但您可以将代码生成为文本或使用.NET面向对象的风格。 T4模板是一种.NET模板机制,虽然最后一次检查,但它不支持 ...
  • 对我来说这看起来像个错误。 来自F#团队的人可能会给出一个明确的答案:-)。 与此同时,这里有一个简单的解决方法,您可以使用 - 问题似乎与=运算符的编译有关。 您可以定义自己的运算符(或函数),并从引用的代码中调用此运算符: let (><) a b = a = b let quote = <@ let value1 = { x = 1; y = 1; } let value2 = { x = 1; y = 1; } let result2 = value1 >< value2 ...
  • 每次通过循环创建一个新对象并不一定意味着该对象不能用作键,只要每次对象比较相等即可。 你将遇到的真正问题是“相同的”引用意味着与F#编译器不同的东西,特别是当涉及引号中的变量时。 例如,您可以验证 <@ [1 + 1] @> = <@ [1 + 1] @> 评估为true ,和 <@ fun x -> x @> = <@ fun y -> y @> 评估为false (希望这是有道理的,因为lambda等同于重命名,但不相同)。 也许更令人惊讶的是,你会看到这一点 <@ fun x -> x @> = ...
  • 最后我看,表现非常糟糕,比F#慢50倍,甚至比天真的翻译慢。 坦率地说,我不明白他们为什么不将F#编译器本身暴露为运行时服务(和FSI)。 如果他们做了F#,他们现在会有更好的工具...... 编辑:我昨晚对运行斐波那契函数的报价进行了基准测试,实际上是700倍! Last I looked, the performance was absolutely awful, around 50× slower than F# and even slower than a naive interpreter. Fr ...
  • 简而言之,这是你的问题: 您正在通过定义方法的类型的实例调用虚方法。 您希望引用包含对派生类上定义的方法的调用。 这不起作用,并且不限于接口或对象表达式: type A() = abstract M : unit -> unit default this.M() = printfn "abstract" type T() = inherit A() with [] override this.M() = p ...
  • 在构造函数中设置属性或可变字段的语法如下: stbuf <- Stat(st_blocks = 0L, st_dev = 1UL) 请注意,您不需要F#中的new ,除了它通常建议在IDisposable事物上。 还要注意指定适当类型的文字所需的后缀。 There's syntax to set properties or mutable fields in the constructor: stbuf <- Stat(st_blocks = 0L, st_dev = 1UL) Note that yo ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。