有没有一种方法可以将两个主键合并为一个,然后级联更新所有受影响的关系?这是场景:
客户(idCustomer int PK,公司varchar(50)等)
CustomerContacts(idCustomerContact int PK,idCustomer int FK,名称varchar(50)等)
CustomerNotes(idCustomerNote int PK,idCustomer int FK,注释文本等)
有时,客户需要合并为一个。例如,您有一个ID为1的客户,另一个ID为2的客户。您想将两者合并,因此现在2的所有内容都为1。我知道我可以编写一个脚本来更新所有受影响的表一个,但是我想通过使用级联规则使其更适合将来使用,因此我不必在每次添加新关系时都更新脚本。
有任何想法吗?
我正在尝试编写符合OpenSearch规范的OpenSearch建议服务.
http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions
此规范要求服务返回JSON数组,第一个元素是字符串,以下元素是字符串数组.我可以通过返回一个字符串数组(string [] [])并让WCF将其序列化为JSON来获得它.但是,为了符合规范,我试图返回一个对象数组(object []),第一个是字符串,其余的是字符串数组(string []).
每当我尝试返回对象数组时,它都不起作用,例如:
来自服务:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SuggestionService : ISuggestionService
{
public object[] Search(string searchTerms)
{
SearchSuggestions = new object[4];
SearchText = searchTerms;
SearchSuggestions[0] = SearchText;
Text = new string[10];
Urls = new string[10];
Descriptions = new string[10];
// Removed irrelevant ADO.NET code
while (searchResultReader.Read() && index < 10)
{
Text[index] = searchResultReader["Company"].ToString();
Descriptions[index] = searchResultReader["Company"].ToString();
Urls[index] = "http://dev.localhost/Customers/EditCustomer.aspx?id=" +
searchResultReader["idCustomer"];
index++;
}
SearchSuggestions[1] = Text;
SearchSuggestions[2] = Descriptions;
SearchSuggestions[3] = Urls;
return …Run Code Online (Sandbox Code Playgroud) 尝试使用 HTTPoison 将图像发布到 Spree 的ProductImage API时,失败并出现 Rails 错误NoMethodError (undefined method 'permit' for #<ActionDispatch::Http::UploadedFile:0x007f94fa150040>)。我用来生成此请求的 Elixir 代码是:
def create() do
data = [
{:file, "42757187_001_b4.jpeg",
{"form-data", [{"name", "image[attachment]"}, {"filename", "42757187_001_b4.jpeg"}]},
[{"Content-Type", "image/jpeg"}]
}, {"type", "image/jpeg"}
]
HTTPoison.post!("http://localhost:3000/api/v1/products/1/images", {:multipart, data}, ["X-Spree-Token": "5d096ecb51c2a8357ed078ef2f6f7836b0148dbcc536dbfc", "Accept": "*/*"])
end
Run Code Online (Sandbox Code Playgroud)
我可以通过以下调用使用 Curl 使其工作:
curl -i -X POST \
-H "X-Spree-Token: 5d096ecb51c2a8357ed078ef2f6f7836b0148dbcc536dbfc" \
-H "Content-Type: multipart/form-data" \
-F "image[attachment]=@42757187_001_b4.jpeg" \
-F "type=image/jpeg" \
http://localhost:3000/api/v1/products/1/images
Run Code Online (Sandbox Code Playgroud)
为了进行比较,下面是失败的 HTTPoison 请求和成功的 Curl 请求的 RequestBin 捕获: https://requestb.in/12et7bp1?inspect
为了让 HTTPoison 与这个 …