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

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

问题描述

我已经习惯了表格和数据集,但现在我想了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.

不过,我得到这样的错误实体类型表名未映射。而这样的事故,我没有一个连接字符串。

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?

推荐答案

有趣的想法。微软很热心,在理论上你可以写映射到任何类型的数据存储的EF提供商。我没有得到一个映射到一个文本文件中的经验,但这种联系表明,谁家有CSV做到了(!):<一href="http://social.msdn.microsoft.com/Forums/ar-SA/adodotnetentityframework/thread/a0e9e20f-66d2-447c-8b7e-75de18535e63?persist=True" rel="nofollow">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 to XML

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

和:实体框架和XML文件

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

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