带有文本文件的实体框架(没有数据库!) [英] Entity Framework with text files (no database!)

查看:35
本文介绍了带有文本文件的实体框架(没有数据库!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯了表单和数据集,但现在我正在尝试 WPF 和实体框架.我的目标是使用实体框架在 WPF 中填充 DataGrid.但是,我没有数据库!我有简单的文本文件,其中包含我必须解析以填充我的实体的数据.

I'm used to Forms and DataSets but now I'm trying out WPF and the Entity Framework. My goal is to fill a DataGrid in WPF with the use of the Entity Framework. However, I do NOT have a database! I have simple text files with data that I have to parse to fill my Entities.

但是,我收到诸如实体类型 'TableName' 未映射"之类的错误.并且像我没有连接字符串那样崩溃.

However, I get errors like "Entity type 'TableName' is not mapped." and crashes like that I don't have a connection string.

是否可以在没有数据库的情况下使用实体框架?还是我必须回去使用 DataSet?

Is it possible to use the Entity Framework without a database? Or do I have to go back to use a DataSet?

推荐答案

有趣的想法.Microsoft 非常热衷于理论上您可以编写一个映射到任何类型数据存储的 EF 提供程序.我没有使用映射到文本文件的经验,但此链接表明有人使用 CSV(!):http://social.msdn.microsoft.com/Forums/ar-SA/adodotnetentityframework/thread/a0e9e20f-66d2-447c-8b7e-75de18535e63?persist=True

Interesting idea. Microsoft's quite enthusiastic that in theory you can write an EF provider that maps to any kind of data store. I've not got experience with one that maps to a text file, but this link suggests that someone's done it with CSV(!): http://social.msdn.microsoft.com/Forums/ar-SA/adodotnetentityframework/thread/a0e9e20f-66d2-447c-8b7e-75de18535e63?persist=True

如果您仍然坚持使用文本文件,为什么不尝试 LINQ转成 XML?

If you're stuck with using text files though, why not try LINQ to XML?

并且:带有 XML 文件的实体框架

这篇关于带有文本文件的实体框架(没有数据库!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆