I just had this error when calling a library from a console app. The library has Entity Framework 6 installed. It turned out the EntityFramework.SqlServer.dll is not copied to the console app's bin folder. You can either manually copy that dll to the bin folder or simply install EF 6 in the console apps.
Wei Ding
Software Developer and Investment Performance Analyst
Sydney, Australia
Friday, February 7, 2014
Tuesday, January 21, 2014
Entity Framework Decimal value truncated/rounded
Recently I found while using Entity Framework to insert Decimal values to SQL database, only two decimal places after the point are saved to database. I'm using EF 6. Still not sure why it acts like this. But the code below fixed the problem.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Rates>().Property(x => x.TheRate).HasPrecision(19, 9);
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Rates>().Property(x => x.TheRate).HasPrecision(19, 9);
}
Friday, January 17, 2014
Entity Framework Datetime comparison problem
Today I had a problem while trying to the 1st line as below, which actually returns records whose ts equals DateTime.Now. Once add .AsEnumerable(), it works. After googling around, it seems LINQ to Entity Framework won't change everything to SQL. Using .AsEnumerable() it will change to LINQ to Object.
1. db.[seeds].Where(s => s.ts < DateTime.Now)
2. db.[seeds]..AsEnumerable().Where(s => s.ts < DateTime.Now)
1. db.[seeds].Where(s => s.ts < DateTime.Now)
2. db.[seeds]..AsEnumerable().Where(s => s.ts < DateTime.Now)
Wednesday, April 10, 2013
.NET, C#, BackgroundWorker Not Responding in Windows 7
After my computer upgraded from Windows XP to Windows 7 (rather late upgrade), I noticed one of my Windows Forms application which using BackgroundWorker would freeze and appear Not Responding after a while. It didn't happen in Windows XP.
I couldn't figure out what caused this, and I have tried the following things in order. It's working but without UI update in ProgressChange. What's the point using BackgroundWorder?
1. add Threading.Sleep(500) after ReportProgress
2. The app used to read from a TreeView in DoWork. I converted it to a List and pass as argument.
3. Completely remove any UI related work in ProgressChange.
I couldn't figure out what caused this, and I have tried the following things in order. It's working but without UI update in ProgressChange. What's the point using BackgroundWorder?
2. The app used to read from a TreeView in DoWork. I converted it to a List and pass as argument.
3. Completely remove any UI related work in ProgressChange.
Monday, April 8, 2013
C# RSS Reader
.Net has SydicationFeed for this purpose. A simple sample as below.
XmlReader r = XmlReader.Create("news.google.com/?output=rss");
SyndicationFeed feed = SyndicationFeed.Load(r);
r.Close();
foreach (SyndicationItem item in feed.Items)
{
var str = string.Format("<a href='{0}'>{1}</a>", item.Links[0].Uri, item.Title.Text);
}
XmlReader r = XmlReader.Create("news.google.com/?output=rss");
SyndicationFeed feed = SyndicationFeed.Load(r);
r.Close();
foreach (SyndicationItem item in feed.Items)
{
var str = string.Format("<a href='{0}'>{1}</a>", item.Links[0].Uri, item.Title.Text);
}
Thursday, April 4, 2013
Google Translate and Microsoft Bing Translator
I was trying to develop a service to programatically translate web pages. From what I learned so far, there're two main translate services offered by Google and Microsoft.
http://translate.google.com/
http://www.bing.com/translator
Both offer API, you just need obtain a key or token. But I couldn't find a way to programmatically post a web page address and then retrieve translated pages. The most can be achieved so far is just post text and get translation.
Also if you don't want to use API (because Google API is a paid service), you still can get transaltion using screen scraping. See links below.
http://www.codeproject.com/Articles/12711/Google-Translator
http://www.west-wind.com/weblog/posts/2011/Aug/06/Translating-with-Google-Translate-without-API-and-C-Code
http://translate.google.com/
http://www.bing.com/translator
Both offer API, you just need obtain a key or token. But I couldn't find a way to programmatically post a web page address and then retrieve translated pages. The most can be achieved so far is just post text and get translation.
Also if you don't want to use API (because Google API is a paid service), you still can get transaltion using screen scraping. See links below.
http://www.codeproject.com/Articles/12711/Google-Translator
http://www.west-wind.com/weblog/posts/2011/Aug/06/Translating-with-Google-Translate-without-API-and-C-Code
Wednesday, April 3, 2013
you have a newer version of NuGet installed that's incompatible with asp.net mvc 3 tools update
While using Microsoft Web Platform Installer today, I encountered this error message "you have a newer version of NuGet installed that's incompatible with asp.net mvc 3 tools update". Obviously there's a conflict here. The easy workaround is to uninstall NuGet from Control Panel (not from Visual Studio). Then re-start the Web Platform Installer.
Subscribe to:
Posts (Atom)