0
我不知道是怎么回事..智能感知不工作 - 无论是与总结标签
我做的EntityFramework上下文的信息库通用模式接口,和我的接口只包含5种方法。
-Query - 插入 -Delete -Synchronize -Dispose
我在摘要部分写的文件,但是当我使用这个类中,智能感知好好尝试一下显示任何信息,所以我尽量感动总结到一个接口,这个类实现了这个接口,但不起作用。
这里是类和接口
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();
}
}
你知道什么是可能发生的事情?