Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

Hope you read my previous post on Windows Phone 7.1 (Mango) local database support. If you didn't read the earlier post, you need to read it before reading this one. You can find it here: "Create DataContext". That will give you the basic context about the same.

 

In this post (I will rather calling it as a Tip), we will configure the project by adding the generated DataContext class and in the next post, we will learn what are the various CRUD operations we can do with a sample application. That will give you complete visibility to this new feature implementation.

 

Index - Windows Phone 7 (Mango) Tutorial

 

This post, I am making a short one just to make sure that, you are doing it step-by-step and understand the various process very easily. In this post we will add the generated class into our project and fix all types of error in the solution. As I mentioned in my previous post, I took help from the article made by WindowsPhoneGeek to resolve these issues. That's an awesome post you should read before continuing to the same feature implementation in your project.

 

The issues that you need to Resolve first

Once I added the NorthwindDataContext class file in the project and built, I faced some issues. First thing that I faced was the build error related to the IDbConnection in the constructors. When I searched on net, I found the solution provided by WindowsPhoneGeek and I removed those two constructors as those are not require for Windows Phone 7.

 

WP7.1 LocalDBDemo - Make NorthwindDataContext class Compatible

 

The second issue that I came across is the missing assembly reference for EntitySet and Linq classes. Once you build the solution, you will notice the following errors:

 

WP7.1 - LocalDatabaseDemo - Compile Error

 

 

The no. of errors will depend on the database class generated by the SqlMetal.exe file. To resolve this, you need to add the System.Data.Linq assembly reference from the Add Reference dialog as shown below:

 

WP7.1 LocalDBDemo - Adding System.Data.Linq Assembly Reference

 

Now once you build the solution it will build properly and your project will be ready to do the database operations by using the exposed APIs of that class.

 

Now it's time to create a small demo project to showcase the CRUD operation in the database. We will explore it in depth tomorrow. Till then enjoy learning other articles.

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.