I'm having a problem with xpath query. I have a schema with two DateTime fields and I need the Max Datetime from all the records in the schema.
this is my Xpath:
xPath_a = "max(/libary/DateTime1)";
any suggestion about how to make it work in Xpath?
Unfortunately, the version of XPath and Xslt supported in .Net still 1.0 so that's what BizTalk uses.
XPath 1.0 does not have a max() function.
Since the syntax you posted suggests an Orchestration, the most practical option is a helper class that takes message as a XmlDocument parameter.
This thread has an example of hot to use an XPathDocument and an XmlDocument: http://social.msdn.microsoft.com/Forums/en-US/e6addfe7-c94f-495b-9e79-35c48844b33f/select-max-value-from-xml-file?forum=xmlandnetfx
This thread provides examples of using XDocument and LINQ: Get max attribute value from XML using LINQ
Related
I am trying to convert XPath queries to predicates that I can use with the QueryBuilder. For example, I have an XPath as follows:
xpath = /jcr:root/content/voda//element(*, cq:PageContent)
[(jcr:contains(#jcr:title,'*') or jcr:contains(.,'*')) and (#cq:template='/apps/cc/templates/people') and (#role!='Other') and #cq:template!='/apps/cc/templates/internalredirect']
/(rep:excerpt(.))
I want to use QueryBuilder instead of XPath.
Also, please suggest some reference material that would help me in general to change other XPath queries to a QueryBuilder format.
Is it possible to use Xpath or Xquery to query XML type fields in a database using Eloquent ORM ? I find in inconvenient to parse the XML every time and filter my results in memory. I would rather return my results from a query, is there a way to achieve that using Eloquent or I'm stuck with raw database statements?
Thank you
I reviewed the options for selecting items in Eloquent and there is not much good options to select based on XML values as you expect. You can use some wildcards and run calculations on Eloquent to filter needed data but none of these are very efficient.
I have to convert property types from String to Long.
Now I want to search with XPath, QueryBuilder,... all properties "prop1" with type String to convert them into Long.
All queries I tried are giving only all nodes where "prop1" exists.
/jcr:root/content/dam/images//element(*,dam:Asset)[jcr:content/metadata/tiff:ImageLength]
Is there a possibility to do that? Because e.g. on http://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html I haven't found anything which helps me.
Greetings
Sören
The only function related to property types offered by the JCR queries is the CAST(), but it doesn't allow you to filter the results. Therefore, you can't find nodes with given property type using XPath, SQL or SQL2. Filter the results manually, using JCR API and the Property#getType() method.
Is there any way to use LIKE operator in LINQ to XML? I did try Googling but it results for Like operator in Linq to SQL not XML.
If yes, please recommend some reference. Thanks a lot in advance.
LINQ to XML is simply LINQ to Objects. LINQ to Objects means that you run .NET code over collections and you can use .NET code to do the filtering. In .NET we can use String.Contains, String.StartsWith and String.EndsWith to check whether a string is part of another string.
I thought that the purpose of using Linq2Nibernate was to return IQueryable and build up an expression tree. I am not sure if this is correct or not.
Why would anyone use Linq2Nibernate if they are not going to return IQueryable?
What else would it be used for?
I would love some more input on this topic
Linq For Nhibernate
I'm planning to use NHibernate.Linq to replace my HQL and criteria API queries with LINQ expressions. In other words, I'll generate the query in code (as a LINQ expression) and then pass it to NHibernate.Linq and NHib to convert it into a database query.
FYI there is an alpha version available.
I have planed to start using Linq2Nibernate but haven't got round to i yet.
My reason for wanting to user Linq2Nibernate is the nice syntax when constructing criterions and later querying them out.
Here is a nice simple example.
http://ayende.com/Blog/archive/2007/03/16/Linq-for-NHibernate.aspx
I am using Linq2Nhibernate with my repository pattern that returns IQueryable objects.
As you know, IQueryable is only a query definition - doesn't touch database yet.
Then local requirements are added to the query and finally the object or list is materialized.
Seems to work excellent and prevents unnecessary db queries for partial data at higher abstract layers.
What's Linq2NHibernate? As there are several projects which tried to implement a linq provider for nhibernate but all stopped before reaching completion.
Any linq provider needs to return IQueryable, or better an IEnumerable as that's how linq works. It's convenient to return an IQueryable as you then can re-use existing code to pad additional operators to an already created query (as ctx.Employee which might return IQueryable is already a query)