Alex KeySmith
Alex KeySmith

Reputation: 17101

Is it possible to use asp.net Dynamic Data with EF + Repository pattern

I'm hoping to scaffold a bunch of web forms pages using asp.net dynamic data. The tutorials fit in nicely when going directly into Entity Framework. However we are using generic repositories (to provide a multi tenancy layer), does anyone have any examples of how a repository pattern can work with dynamic data?

Upvotes: 1

Views: 279

Answers (1)

Ash Machine
Ash Machine

Reputation: 9911

I'm doing Linq to SQL with a Repository pattern, and EF with repository pattern is possible also.

public class BaseRepository : IDisposable
    {
        protected MyDataContext dc = null;
        private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();        
        protected BaseRepository()
        {
            dc = new MyDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["My_ConnectionString"].ConnectionString, mappingSource);
        }
    }

I have an interface to my Object Repository :



interface IObjectRepository
    {
    ...
    }

and the object Repository:



public class ObjectRepository : BaseRepository, IObjectRepository
    {
        private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public ObjectRepository()
        {
                IList<Foo> GetFoos = GetFoos()
{
...
}
        }
    }

Upvotes: 1

Related Questions