我不知道发生了什么......
我为EntityFramework上下文做了一个Repository Generic Pattern Interface,我的界面只包含5个方法。
-Query -插入 -删除 -Synchronize -Dispose
我在Summary Section中编写了文档,但是当我使用这个类时,intelisense不会显示任何信息,所以我尝试将摘要移动到一个接口,这个类实现了该接口,但也不起作用。
以下是类和接口
public interface IRepositorySource : IDisposable
{
/// <summary>
/// Allow Queries with LINQ to Entities throught IQueryable interface
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>Teste</returns>
IQueryable<T> Query<T>() where T : class;
/// <summary>
/// Insert the e object in specific table.
/// The inserted object is only on database after Synchronize was called.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="e"></param>
void Insert<T>(T e) where T : class;
/// <summary>
/// Delete the e object from specific table.
/// The deleted object is only removed from database after Synchronize was called.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="e"></param>
void Delete<T>(T e) where T : class;
/// <summary>
/// Synchronize the database with all pending operations.
/// </summary>
void Synchronize();
/// <summary>
/// Free all managed resources such the connection and ObjectContext associated with the repository
/// </summary>
void Dispose();
}
/// <summary>
/// By inherit from this class, you get the Repository Patter to query the datasource.
/// </summary>
public class RepositoryBase : IRepositorySource, IDisposable
{
readonly ObjectContext m_context;
public RepositoryBase(ObjectContext context)
{
if ( context == null )
throw new ArgumentNullException("context");
m_context = context;
}
ObjectSet<T> Table<T>() where T : class {
//
// As the entity framework creates the properties with the same name of the Type we want to access,
// it is really easy to map those types to properties throught reflection
// Get the property of the context with the name of the type.
//
return (ObjectSet<T>) m_context.GetType().GetProperty(typeof(T).Name).GetValue(m_context, null);
}
public IQueryable<T> Query<T>() where T : class {
return Table<T>();
}
public void Insert<T>(T e) where T : class {
Table<T>().AddObject(e);
}
public void Delete<T>(T e) where T : class {
Table<T>().DeleteObject(e);
}
public void Synchronize() {
m_context.SaveChanges();
}
public void Dispose() {
m_context.Dispose();
}
}
你知道可能发生了什么吗?
答案 0 :(得分:2)
我找到的解决方案是通过Visual Studio,单击类库项目,属性,构建,XML文档文件检查。