Oracle 中 System.Data.Linq.DataContext 的等价物是什么?
我正在针对 Oracle 数据库实现 IRepository 接口。
public interface IDinnerRepository {
IQueryable<Dinner> FindAllDinners();
IQueryable<Dinner> FindByLocation(float latitude, float longitude);
IQueryable<Dinner> FindUpcomingDinners();
Dinner GetDinner(int id);
void Add(Dinner dinner);
void Delete(Dinner dinner);
void Save();
}
我应该如何实现 Save 方法?如果我使用 Linq2Sql,我将创建一个数据库上下文,然后在数据库上下文上调用 SubmitChanges。如何使用 Oracle 后端实现相同的功能?
/// <summary>
/// Database context
/// </summary>
private DBDataContext db = new DBDataContext();
public void Save()
{
this.db.SubmitChanges();
}
谢谢!
I am implementing the IRepository interface against an Oracle database.
public interface IDinnerRepository {
IQueryable<Dinner> FindAllDinners();
IQueryable<Dinner> FindByLocation(float latitude, float longitude);
IQueryable<Dinner> FindUpcomingDinners();
Dinner GetDinner(int id);
void Add(Dinner dinner);
void Delete(Dinner dinner);
void Save();
}
How should I implement the Save method? If I was working with Linq2Sql I would create a database context and then call SubmitChanges on the database context. How can I implement the same functionality with an Oracle back end?
/// <summary>
/// Database context
/// </summary>
private DBDataContext db = new DBDataContext();
public void Save()
{
this.db.SubmitChanges();
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想使用 Oracle 的 LinqToSql 等效项,CodePlex 上有一个 LinqToOracle 项目。它提供了
OracleDataContext
以及您需要的所有其他内容。然而,最近一次签入是在 2010 年 7 月 20 日,所以没有发生太多事情。您还可以开始使用 LinqToEntities,它被设计为独立于平台。但是,我只能找到商业 提供商。这是关于将 Oracle 与 ADO.NET 结合使用的另一个 SO 问题实体框架。
If you want to use the LinqToSql equivalent for Oracle, there is a LinqToOracle project on CodePlex. It provides an
OracleDataContext
and everything else you need. However, the most recent checkin is from July 20, 2010 so there's not a lot going on there.You could also start using LinqToEntities which was designed to be platform-independent. However, I can only find a commercial provider. Here's another SO question on using Oracle with the ADO.NET Entity Framework.
我找到了一个很好的解决方案,不需要我花钱购买第三方工具。我正在使用 NHibernate 进行数据访问。 LinqToSql DataContext 对象的等效对象是 NHibernate Session 对象。这使我能够使用 Oracle 以事务方式执行 CRUD 操作。谢谢!
I found a good solution that doesn't require me to spend money on a 3rd party tool. I am using NHibernate for my data access. The equivalent for the LinqToSql DataContext object is the NHibernate Session object. This allows me to perform CRUD operations transactionally with Oracle. Thanks!