如何使用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
最满意答案
实际上,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#报价评估问题(F# quotation evaluation issue)[2023-09-20]
对我来说这看起来像个错误。 来自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 ...