使用模式名称访问Simple.Data表会引发错误

时间:2013-09-03 13:15:12

标签: c# asp.net-mvc-4 simple.data

我在Asp.Net MVC 4应用程序中使用Simple.Data for Oracle版本0.18.3.1。它适用于不在模式名称之前的表,但是当我尝试从必须在模式名称之前的表中获取数据时崩溃。我收到的错误是

"No matching table found, or insufficient permissions."

我需要执行的查询如下:

SELECT * FROM SchemaName.TableName

当我尝试在Oracle Sql Developer中执行它时,此查询正常工作。我得到了结果。但是在C#中使用Simple.Data获得上述错误。我尝试了以下方法:

//BASE CLASS
public class BaseRepository
{
    protected dynamic DB { get; set; }
    public BaseRepository()
    {
        DB = Database.OpenNamedConnection("intranet_db");
    }
}

//Derived Class
public class EmployeeRepository : BaseRepository
{
    public List<Employee> GetEmployees()
    {                
        List<Employee> employees = DB.SchemaName.TableName.FindAllBy(JoinedOn:"2009-05-31");

        // I also have tried the following combinations as specified in documentations
        // DB.SchemaName["TableName"].FindAllBy(JoinedOn:"2009-05-31");
        // DB["SchemaName"].TableName.FindAllBy(JoinedOn:"2009-05-31");
        // DB["SchemaName"]["TableName"].FindAllBy(JoinedOn:"2009-05-31");

        return employees;
    }
}

但它不断抛出上述错误。

我做错了什么?

提前致谢。

修改

以下是主要exeption的Stack Traces及其InnerException。

STACK TRACE

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Simple.Data.SimpleQuery.TryConvertToGenericCollection(ConvertBinder binder, Object& result, Type collectionType)
at Simple.Data.SimpleQuery.TryConvert(ConvertBinder binder, Object& result)
at CallSite.Target(Closure , CallSite , Object )
at MyProject.Repository.Repositories.EmployeeRepository.GetStoppedEmployees() in d:\Projects.Net\MyProject\MyProject.Repository\Repositories\EmployeeRepository.cs:line 11
at MyProject.Web.Controllers.HomeController.Index() in d:\Projects.Net\MyProject\MyProject.Web\Controllers\HomeController.cs:line 17
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.b__41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()

INNER EXCEPTION STACK TRACE

at Simple.Data.Ado.Schema.TableCollection.Find(String tableName, String schemaName)
at Simple.Data.Ado.Schema.TableCollection.Find(ObjectName tableName)
at Simple.Data.Ado.Schema.DatabaseSchema.FindTable(ObjectName tableName)
at Simple.Data.Ado.QueryBuilderBase.SetQueryContext(SimpleQuery query)
at Simple.Data.Oracle.OracleQueryBuilder.Build(SimpleQuery query, IEnumerable1& unhandledClauses)
at Simple.Data.Oracle.OracleCustomQueryBuilder.Build(AdoAdapter adapter, Int32 bulkIndex, SimpleQuery query, IEnumerable1& unhandledClauses)
at Simple.Data.Ado.QueryBuilder.Build(SimpleQuery query, IEnumerable1& unhandledClauses)
at Simple.Data.Ado.AdoAdapterQueryRunner.GetQueryCommandBuilders(SimpleQuery& query, IEnumerable1& unhandledClauses)
at Simple.Data.Ado.AdoAdapterQueryRunner.RunQuery(SimpleQuery query, IEnumerable1& unhandledClauses)
at Simple.Data.Ado.AdoAdapter.RunQuery(SimpleQuery query, IEnumerable1& unhandledClauses)
at Simple.Data.DatabaseRunner.RunQuery(SimpleQuery query, IEnumerable`1& unhandledClauses)
at Simple.Data.SimpleQuery.Run()
at Simple.Data.SimpleQuery.CastT

0 个答案:

没有答案