Use UTF-8 encoding for StringWriter in C#

All .NET string is in Unicode (UTF-16) encoding format. So when you are using StringWriter to create your XML it will use UTF-16 encoding. Example when creating XML : var serializer = new XmlSerializer(yourModel.GetType(), string.Empty); var stringBuilder = new StringBuilder(); using (var stringWriter = new StringWriter()) { serializer.Serialize(stringWriter, yourModel); stringBuilder.…

Monitoring data change using SqlDependency and C#

What is SqlDependency? As the word describes itself, it is used to notify your application or user when certain criteria or condition is satisfied. This condition (query in technical terms) is provided to SQL notification service to be observed upon and ask to be notified when the condition is met…

Stop Slumdog Blogging

What is wrong with you people? Slumdog blogging? Seriously? Answer.com says Slumdog is – Basically a poor kid coming from poverty stricken areas. I am not criticizing the authors who really can’t afford. But it seems most of them are ignorant enough. Why Blog? Everyone will definitely have one…

Code First using Entity Framework 5 with example

This will provide you the simple and fastest way to get started with the Code First Approach using Entity Framework 5. For the purpose of this demo, I am going to use WPF application and MVVM (light toolkit). But this can be done with other types of projects too. Conceptually…