Comments (6)
The stack trace is telling you that it isn't able to parse the query. Could
you post the exact parameters and the way you call NHibernate.OData? Maybe
that helps to look at your issue.
On Sat, Dec 14, 2013 at 4:02 PM, Riderman [email protected] wrote:
I'm having trouble running queries with $expand or substringof, the
following error is generated{
"odata.error": {
"code": "",
"message": {
"lang": "en-US",
"value": "An error has occurred."
},
"innererror": {
"message": "Exception has been thrown by the target of an invocation.",
"type": "System.Reflection.TargetInvocationException",
"stacktrace": " at System.Web.Http.ApiController.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__0.MoveNext()",
"internalexception": {
"message": "Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [.Take[AeCAudit.Dominio.GrupoUsuario](.OrderBy[AeCAudit.Dominio.GrupoUsuario,System.Int32]%28.Where[AeCAudit.Dominio.GrupoUsuario]%28NHibernate.Linq.NhQueryable1[AeCAudit.Dominio.GrupoUsuario], Quote%28%28$it, %29 => %28Equal%28Equal%28Or%28Equal%28Convert%28$it.Nome%29, NULL%29, p1%29 ? NULLp3 : Convert%28Convert%28$it.Nome%29.Contains%28p2, %29%29, p4%29, p5%29%29%29, %29, Quote%28%28$it, %29 => %28$it.Id%29%29, %29, p6,)]", "type": "NHibernate.Hql.Ast.ANTLR.QuerySyntaxException", "stacktrace": " at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()\r\n at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()\r\n at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary
2 replacements, Boolean shallow, String collectionRole)\r\n at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary2 filters, ISessionFactoryImplementor factory)\r\n at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary
2 filters, ISessionFactoryImplementor factory)\r\n at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary2 enabledFilters)\r\n at NHibernate.Impl.AbstractSess ionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)\r\n at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)\r\n at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery)\r\n at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)\r\n at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)\r\n at Remotion.Linq.QueryableBase
1.GetEnumerator()\r\n at System.Collections.Generic.List1..ctor(IEnumerable
1 collection)\r\n at System.Web.Http.OData.Query.TruncatedCollection1..ctor(IQueryable
1 source, Int32 pageSize)\r\n at System.Web.Http.OData.Query.ODataQueryOptions.LimitResults[T](IQueryable`1 queryable, Int32 limit, Boolean& resultsLimited)"
}
}
}}How can I use in conjunction with Asp.net and webapi so that the queries
sent from the client (HTTP GET) are translated in server and send back to
the client?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/8
.
from nhibernate.odata.
Any query with $substringof
or $expand
this error is raised
{{odata}}/ArquivosVenda?$filter=substringof('ex', FileName)
from nhibernate.odata.
I made a video demonstrating the problem. Follow the link: http://screenr.com/WdVH
public class ArquivoVenda: IAuditavel, IEntidade
{
public virtual int Id { get; set; }
public virtual string FileName { get; set; }
public virtual ICollection<Venda> Vendas { get; set; }
public virtual ICollection<ImportacaoVendaErro> Erros { get; set; }
[DefaultValue("getdate()")]
public virtual DateTime CriadoEm { get; set; }
public virtual Usuario CriadoPor { get; set; }
public virtual DateTime? AtualizadoEm { get; set; }
public virtual Usuario AtualizadoPor { get; set; }
}
Packages:
Microsoft.AspNet.WebApi 5.0.0
Microsoft.AspNet.WebApi.Client 5.0.0
Microsoft.AspNet.WebApi.Core 5.0.0
Microsoft.AspNet.WebApi.OData 5.0.0
Microsoft.AspNet.WebApi.Web... 5.0.0
Api
public class ArquivosVendaController : BaseEntidadeController<ArquivoVenda>
{
public ArquivosVendaController(IArquivosVendaRepositorio repositorio)
: base(repositorio)
{ }
public IQueryable<Venda> GetVendas([FromODataUri] int key)
{
return Repositorio.Get(key).Vendas.AsQueryable();
}
}
public abstract class BaseEntidadeController<TEntidade> : ODataController
where TEntidade : class, IEntidade
{
protected IRepositorio<TEntidade> Repositorio { get; private set; }
public BaseEntidadeController(IRepositorio<TEntidade> repositorio)
{
Repositorio = repositorio;
}
[HttpGet, Queryable(AllowedQueryOptions = AllowedQueryOptions.All, PageSize = 25, MaxExpansionDepth = 3)]
public IQueryable<TEntidade> Get()
{
return Repositorio.All();
}
[Queryable(MaxExpansionDepth = 3)]
public virtual SingleResult<TEntidade> Get([FromODataUri]int key)
{
return SingleResult.Create<TEntidade>(Repositorio.Query(c => c.Id == key));
}
[HttpGet]
protected virtual TEntidade GetEntityByKey(int key)
{
return Repositorio.All().FirstOrDefault(p => p.Id == key);
}
}
from nhibernate.odata.
I'm not using NHibernate.OData, would like to know how to use it in conjunction with the webapi?
I believe the problem is because NHibernate can not translate these queries, and that NHibernate.OData can solve this. But how to use it in conjunction with the webapi?
Recalling that the application is a Asp.net MVC 5
from nhibernate.odata.
Ah, I understand. I don't know about webapi, so I'm afraid I would not be
able to help you. The demo project in the NHibernate.OData repository shows
how you can integrate NHibernate.OData as a proper OData provider. Maybe
you can use this as a starting point.
On Sat, Dec 14, 2013 at 5:41 PM, Riderman [email protected] wrote:
I'm not using NHibernate.OData, would like to know how to use it in
conjunction with the webapi?I believe the problem is because NHibernate can not translate these
queries, and that NHibernate.OData can solve this. But how to use it in
conjunction with the webapi?Recalling that the application is a Asp.net MVC 5
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-30580273
.
from nhibernate.odata.
Ok, I'll take a look. I found this link but I could not quite understand how you can help me. Thank you!
from nhibernate.odata.
Related Issues (20)
- Implement duration support
- Incorrect operator precedence HOT 1
- OData 4 support HOT 1
- Additional OData query options support HOT 1
- Support for DTOs HOT 6
- Member resolving is not tested
- CaseSensitive parameter not working HOT 5
- Issue with Any in OData $filter clause. HOT 2
- Support $count and &inlinecount HOT 1
- Query is not supported with substringof and 3 or more clauses HOT 2
- Any/All with collections of basic types.
- "Not Contains" clause not works HOT 2
- `bigint`/`long` overflow
- Implement a sample project implementing a full OData service HOT 4
- .NET Standard compatible
- Filtering on null throws exception HOT 2
- Allow column names to be specified case insenstive HOT 1
- indexof parameters are swapped for sql HOT 1
- substringof - which is correct implementation? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nhibernate.odata.