2017年3月5日 星期日
Could not load file or assembly 'Microsoft.CodeAnalysis, version= 1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
2016年11月10日 星期四
MVC網站使用多個資料庫(Code First)
- 下命令時需指定使用哪個DataContext
- -Verbose 可以觀察migration流程
- enable-migrations -ContextTypeName MultiDataContextMigrations.Models.DataContext -MigrationsDirectory:DataContextMigrations
- Add-Migration -configuration MultiDataContextMigrations.DataContextMigrations.Configuration Initial
- Update-Database -configuration MultiDataContextMigrations.DataContextMigrations.Configuration -Verbose
2016年11月9日 星期三
MVC用EF存取MYSQL資料庫時產生的不明問題解決方式
以現有資料庫產生EF架構,有時候會發現,在寫入資料時會有不明原因的報錯
錯誤訊息 Error “You have an error in your sql syntax entity framework” with Entity Framework
目前查到的解決方法如下:
1. 右鍵點擊產生的edmx檔,用有編碼的xml打開
2. 搜尋DefiningQuery 這個Tag,然後把它砍了
3. 之後就一切正常了
參考網頁
What happened is that at the moment of executing
錯誤訊息 Error “You have an error in your sql syntax entity framework” with Entity Framework
目前查到的解決方法如下:
1. 右鍵點擊產生的edmx檔,用有編碼的xml打開
2. 搜尋DefiningQuery 這個Tag,然後把它砍了
3. 之後就一切正常了
參考網頁
What happened is that at the moment of executing
db.SaveChanges() (after an update), the .edmx tried to update the rows in the 'C' table, but as this table only had two foreign keys to A and B, the update operation wasn't supported. This is the solution that I found in other post in StackOverflow, and it worked for me:- Right click on the edmx file, select Open with, XML editor
- Remove the DefiningQuery entirely
- Rename the
store:Schema="dbo"toSchema="dbo(remove the "store:") - Remove the
store:Name=...property (entirely)
2016年10月20日 星期四
比較兩個List , List Compare, var a = SequenceEqual & Equal ignore order
使用linq函式
1.完全符合
var a = ints1.SequenceEqual(ints2);
2.無視順序
To ignore order, use SetEquals:
var a = new HashSet(ints1).SetEquals(ints2);
2016年10月5日 星期三
EF with MySQL syntax error 解決辦法
mvc網站對mySql建立entity之後,在新增時出錯
錯誤內容:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near: {SQL COMMAND}
1.Right click on the edmx file, select Open with, XML editor
2.Remove the DefiningQuery entirely
3.Rename the store:Schema="dbo" to Schema="dbo (remove the "store:")
4.Remove the store:Name=... property (entirely)
2016年6月19日 星期日
UserControl 自我綁定
在套用UserControl時,宣告DataContext為
DataContext="{Binding RelativeSource={RelativeSource Self}}"
否則會與套用者綁定
2015年11月23日 星期一
避免children control 的事件觸發parent的事件
今天寫了一個滑鼠移入與點擊時觸發的選單,裡面放了幾個按鈕,發現按鈕的mouseenter事件,會連帶觸發容器的mouseenter事件
找了一下發現可以用以下方式來避免
$(document).ready(function(){
$(".header").click(function(){
$(this).children(".children").toggle();
});
$(".header a").click(function(e) {
e.stopPropagation();
});
});
訂閱:
文章 (Atom)