我目前正在使用CRM 2015 SDK.我只是尝试使用此SDK更新C#中的值.但由于某些原因,我试图弄清楚,当我保存我的时候会遇到麻烦context.
有代码:
foreach (KeyValuePair<string, Account> account in dicAccount)
{
//Calcul of url/login/date/key/customer values
string generatedUrl = Utilities.GenerateURL(url, login, date, key, customer);
account.Value.new_Link = generatedUrl;
if (!context.IsAttached(account.Value))
{
context.Attach(account.Value);
}
context.UpdateObject(account.Value);
}
SaveChangesResultCollection results = context.SaveChanges(SaveChangesOptions.ContinueOnError);
if (results != null)
{
foreach (SaveChangesResult result in results)
{
Type type = result.Request.GetType();
bool hasError = result.Error != null;
Entity entity = (Entity)result.Request.Parameters["Target"];
if (type == typeof(UpdateRequest))
{
if (hasError)
{
if (entity != null)
{
log.Error(result.Error.Message);
}
} …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个正则表达式来将 sql 语法转换为 Postgres 语法。我正在使用 geany 来替换文本。目前,我尝试更改的语法是:
INSERT IGNORE INTO item_question_ (question_fk_,item_fk_) VALUES(1002,162);
Run Code Online (Sandbox Code Playgroud)
进入 :
INSERT INTO item_question_ (question_fk_,item_fk_) VALUES (1002,151)
WHERE NOT EXISTS
(SELECT 1 FROM item_questionnaire_ WHERE question_fk_=1002 AND item_fk_ = 151)
Run Code Online (Sandbox Code Playgroud)
我很接近,但绝对还不够。我有这个正则表达式:
(INSERT IGNORE INTO (.*)_ (.*) VALUES(.*);) //Find information
INSERT INTO \2_ \3 VALUES \4 WHERE NOT EXISTS (SELECT 1 FROM \2_ WHERE )// Transform information
Run Code Online (Sandbox Code Playgroud)
事实上,我遗漏了最重要的部分:条款WHERE。
我如何获取该值question_fk_,item_fk_并1002,151构建我的 where 子句?
附加说明:Postgres 版本低于 9.5。我不能使用ON CONFLICT IGNORE
[Symfony\Component\Debug\Exception\FatalErrorException] 语法错误,意外的 '(',需要标识符 (T_STRING) 或变量 (T_VARIABLE) 或 '{' 或 '$'
这是我的代码
public function up()
{
Schema::create('profile', function (Blueprint $table) {
$table->('userid')->unsigned()->default(0);
$table->string('profile')->default('http://localhost/laravel/public/image/uzair.jpg');
$table->string('about',255);
$table->foreign('userid')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud)