我希望使用asp.net 动态数据搭建一堆 web 表单页面。当直接进入实体框架时,这些教程非常适合。但是,我们正在使用通用存储库(提供多租户层),有没有人有任何关于存储库模式如何处理动态数据的示例?
问问题
274 次
1 回答
1
我正在使用存储库模式执行 Linq to SQL,并且使用存储库模式的 EF 也是可能的。
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()
{
...
}
}
}
于 2012-03-22T22:01:09.363 回答