1

I had many doubts regarding Database in windows Phone Mango.

  1. In WP7 mango how i can enter/Insert a list of objects or observable collection to a table

  2. I had a database (*.sdf) with me that contains some data, I used SQLMetel and i created a .cs file; but while reading that cs file it's showing plenty of irrelevent information.

My question is from that automatically generated cs file, how I can split the generated information based on my independent tables. i.e. I need to keep the information of each table in two separate cs files. For example, the student database contains student details and parents details. While creating the cs file with sql metal it's only giving a single file that contains both table related data. I need to split this table info to two independent .cs files. What do I need to do to do this?

1 Answer 1

2

Why do you want to split the entity classes in separate files. You can use classes generated for all tables and ignore those that you do not want to.

But if you must, here is one way. Generate an intermediate dbml file, edit it and then generate the code using dbml file(s). Say you have two tables student and parent in database.sdf

  1. run:SqlMetal.exe /dbml:database.dbml database.sdf
  2. Copy the database.dbml file to student.dbml and parent.dbml
  3. Edit student.dbml and remove the XML node for parent. Similarly edit parent.dbml and delete the XML node for student
  4. run: SqlMetal.exe /code:database1.cs student.dbml and SqlMetal.exe /code:database2.cs parent.dbml

Since it generates the classes as partial classes, you should be able to include both files in your project. (You will need to delete constructors that you use IDbConnection from both files)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.