开发者

What's the Oracle equivalent of System.Data.Linq.DataContext?

开发者 https://www.devze.com 2023-01-18 00:11 出处:网络
I am implementing the IRepository interface against an Oracle database. public interface IDinnerRepository {

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 开发者_如何学Pythonsame functionality with an Oracle back end?

    /// <summary>
    /// Database context
    /// </summary>
    private DBDataContext db = new DBDataContext();

    public void Save()
    {
        this.db.SubmitChanges();
    }

Thanks!


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.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号