开发者

Implementing Database in WP7 Mango

开发者 https://www.devze.com 2023-04-07 15:37 出处:网络
I had many doubts regarding开发者_JAVA技巧 Database in windows Phone Mango. In WP7 mango how i can enter/Insert a list of objects or observable

I had many doubts regarding开发者_JAVA技巧 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?


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号