在 WP7 Mango 中实现数据库
我对 windows Phone Mango 中的数据库有很多疑问。
在 WP7 mango 中,我如何输入/插入对象或可观察对象的列表 集合到表
我有一个数据库(*.sdf),其中包含一些数据,我使用 SQLMetel 和我创建了一个 .cs 文件;但是在读取 cs 文件时 它显示了大量不相关的信息。
我的问题是来自自动生成的 cs 文件,如何根据我的独立表拆分生成的信息。即我需要将每个表的信息保存在两个单独的cs文件中。例如,学生数据库包含学生详细信息和家长详细信息。在使用 sql Metal 创建 cs 文件时,它只提供一个包含两个表相关数据的文件。我需要将此表信息拆分为两个独立的 .cs 文件。我需要做什么才能做到这一点?
I had many doubts regarding Database in windows Phone Mango.
In WP7 mango how i can enter/Insert a list of objects or observable
collection to a tableI 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要将实体类拆分到单独的文件中。您可以使用为所有表生成的类并忽略那些您不想要的类。
但如果你必须这样做,这里有一种方法。生成中间 dbml 文件,对其进行编辑,然后使用 dbml 文件生成代码。假设您在database.sdf中有两个表student和parent,
SqlMetal.exe /dbml:database.dbml database.sdf
SqlMetal.exe /code:database1.cs Student.dbml
和SqlMetal.exe /code:database2.csparent.dbml< /code>
由于它将类生成为部分类,因此您应该能够在项目中包含这两个文件。 (您需要从两个文件中删除使用 IDbConnection 的构造函数)
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
SqlMetal.exe /dbml:database.dbml database.sdf
SqlMetal.exe /code:database1.cs student.dbml
andSqlMetal.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)