I got System.BadImageFormatException when I was using SQLite
I had built a new application using System.Data.Sqlite. When I run the application, I got an exception, System.BadImageFormatException.Well, I found I was using 64-bit version, because System.Data.Sqlite will call some unmanaged dlls. So, it still needs to be in 32-bit. After I changed to use 32-bit dll,then all goods. Or you can switch your build target to 64 bit and using 64 bit dlls.
Learning Silverlight
I wish to a rich user interface for my website. Well, HTML 5 is the best choice. But HTML 5 is still not easy to do some tasks, such as animations and charting. Then, Flash is the second best choice. A lot of platforms support this. But I need to learn it from scratch. In this case, Silverlight is a much better option. It is similar with WPF which I have learnt before.Moreover, the Silverlight is a component-based components. I can use some third-party controls to build the interface. Those third-party controls can be download from internet freely or just needs to pay a small amount of money. This can reduce the amount of coding. So, I choose to learn Silverlight
Silverlight 4 Toolkit - April 2010 - Unknown Namespace Error
I have installed Silverlight 4 Toolkit - April 2010. I tried to drop a component in a xaml. But I got an error,
"Unknown namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit". I searched a solution for a while, but no luck at all! Finally, I got the cause I forgot to install Silverlight SDK4! I am so silly!
After I installed it, that works! Please remember set your visual studio project to use Silverlight 4 too!
Getting Row Count in NHibernate
Getting the row count of a table, that is easy in NHibernate. You can do it this way:
Code
ICriteria criteria = CurrentSession.CreateCriteria<Member>(); | |
criteria.Add(Expression.Eq("Code",code)); | |
return (int) criteria.List().Count; |
But this is very heavy weighted. You are retrieving a whole list of objects!!!! But you just need to know the numbers of objects! You are wasting a lot of processing power!
You can do it this way. That is only getting a row count, just a number! Therefore, a "select count(*)" query is executed.
Code
ICriteria criteria = CurrentSession.CreateCriteria<Member>(); | |
criteria.Add(Expression.Eq("Code",code)); | |
criteria.SetProjection(Projections.RowCount()); | |
return (int) criteria.UniqueResult(); |
Inconsistency between windows by NHibernate.
I am writing a library management system for church. This is using Spring.Net and NHibnerante. But I faced a problem. After the user updated in a record window, the record in the main window did not get updated. I have read Spring.net Tutorial. That is nothings wrong. Even I forced the session flush. But that did not work. In the session of the record edit window, the fields are updated. When I jumped back to Main Window, the session is updated. Finally, I found the problem in the Transaction attribute. In the DAO, the code should be written like this:
Code
[Transaction(ReadOnly = true)] | |
public IList<TEntity> GetAll() | |
{ |
And the update method
Code
[Transaction] | |
public void Save(TEntity entity) | |
{ |
