是否可以在没有LINQ的情况下使用实体框架? [英] Is it possible to use Entity Framework without LINQ?

查看:76
本文介绍了是否可以在没有LINQ的情况下使用实体框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用不带LINQ(对实体的linq)的实体框架?

Is it possible to use Entity Framework without LINQ (linq to entities)?

推荐答案

不清楚分别使用Linq to Entities和EF是什么意思.那是一个单独的库 EntityFramework.dll .如果要在普通SQL上编写查询,则可以使用

It's not clear what you mean by using Linq to Entities and EF separately. That's a single library EntityFramework.dll. If you want to write queries on plain SQL, you can do it with SqlQuery() method of DbSet class:

var users = context.Users.SqlQuery("SELECT * FROM dbo.Users").ToList();

在这种情况下,EF仅充当映射器,但不会生成查询.

In this case EF acts only as mapper, but it does not generates query.

更新根据您的评论,您希望避免引用Linq.答案是-您做不到,因为EF引用了 System.Linq 命名空间.考虑将NHibernate与Criteria API一起使用.

UPDATE According to your comments, you want to avoid referencing Linq. And the answer is - you can't do that, because EF references System.Linq namespace. Consider to use NHibernate with Criteria API.

请记住-Linq已集成到语言中.最好花一些时间来解决它,而不是避免它. Linq非常强大,您不仅可以将其用于数据库访问,而且还可以用于日常处理内存中的集合,xml,数据集等.

And remember - Linq is integrated into language. Better spend some time getting around it, than avoid it. Linq is very powerful and you will use it not only for database access, but for everyday working with in-memory collections, xml, datasets and so on.

这篇关于是否可以在没有LINQ的情况下使用实体框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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