var assets1 = data.SelectNodes("//asset[#id]=" + oldBinaryAssetId);
var assets2 = data.SelectNodes("//Asset[#id]=" + oldBinaryAssetId);
Is it possible to make 1 xpath query of the two above?
Your XPath is wrong to be gin with. You probably mean:
data.SelectNodes("//Asset[#id = '" + oldBinaryAssetId + "']");
To combine both variants (upper- and lower-case), you could use:
data.SelectNodes("//*[(name() = 'Asset' or name() = 'asset') and #id = '" + oldBinaryAssetId + "']");
or
data.SelectNodes("(//Asset | //asset)[#id = '" + oldBinaryAssetId + "']");
If you have any way to avoid the // operator, I recommend doing so. Your queries will be faster when you do, though this might only be noticable with large input documents.
Related
I have looked at this plunker.
http://plnkr.co/edit/WJzTr8AR8dhWIjXELNY1?p=preview
It filters on first characters. Has anyone attempted to perform this filtering based on a substring search. If so please let me know
I worked on modifying the filter text as shown
angular.forEach(filterBarPlugin.scope.columns, function(col) {
if (col.visible && col.filterText) {
var filterText = (col.filterText.indexOf('*') == 0 ? col.filterText.replace('*', '') : col.filterText + "^") + ";";
searchQuery += col.displayName + ": " + filterText;
}
});
The original plunkr is design filtering from the beginning characters. If you went to filtering from the substring, you can try * begin filter textbox.
If you don't like it, you can modify filterBarPlugin function :
var filterText = (col.filterText.indexOf('*') == 0 ? col.filterText.replace('*', '') : "^" + col.filterText) + ";";
searchQuery += col.displayName + ": " + filterText;
To
var filterText = col.filterText +'; ';
searchQuery += col.displayName + ": " + filterText;
Example
updated: fixed not allow for multiple column sorting, thanks #mainguy
This is not really an answer but more an update to #allyusd's answer.
He is basically right, but his wildcardless solution does not allow for multi column sorting because a semicolon is missing.
With these small changes:
angular.forEach(filterBarPlugin.scope.columns, function(col) {
if (col.visible && col.filterText) {
var filterText = col.filterText +'; ';
searchQuery += col.displayName + ": " + filterText;
}
});
you can filter in this plunk for name=or AND age=4 and you will get Enors as result.
As I said: Just an update, kudos to allyusd!
I am trying very hard to make my cascading select decorate using telerik form decorator. Here is my js,
var attributes = s.attributes;
for (var i = 0, iLen = attributes.length; i < iLen ; i++) {
$elem.append('<option ' + (selectedValue === attributes[i].id ? 'selected ' : '') + 'value="' + attributes[i].id + '">' + attributes[i].name + '</option>');
}
after this I am calling,
formDecorator.decorate($elem[0], false);
It only works first time when the parent select changed(in a cascading select). But after this nothing works. I have tried,
formDecorator.decorate();
and
formDecorator.updateSelect($elem[0]);
Is there is any way to make it work?
A quick search in Telerik's forums gave me this thread that seems to have a useful response: http://www.telerik.com/community/forums/aspnet-ajax/form-decorator/cascading-select-in-javascrip-and-telerik-radformdecorator.aspx. I would give it a try and post there for more people to see. I hope it helps you.
i wan to retrieve data from query involving many tables.
i have a query as follows
String sql = "SELECT "
+ "s.Food_ID AS 'Sales_FoodID', "
+ "f.Food_Name AS 'foodName' "
+ "FROM Ordering o, Sales s, Food f"
+ " WHERE o.Table_No = " + tableNo + ""
+ " AND o.Paid = '" + NOT_PAID + "'"
+ " AND s.Order_ID = o.Order_ID"
+ " AND f.Food_ID = s.Food_ID;";
resultSet = statement.executeQuery(sql);
no error were found when i run the program, but after i add this line to get a table's column data:
String orderID = resultSet.getString("foodName");
i'm given this error:
java.sql.SQLException: Column not found
anyone know why?
You have to use next() method.
You should know that ResultSet is implicitly positioned on position before first row so you need to call next to get current position and if is valid, it returns true, else returns false (cursor is positioned after the last row).
rs = statement.executeQuery(sql);
while (rs.next()) {
String orderID = rs.getString(2);
}
Note: You can use also rs.getString(<columnName>) but in case when you know how your statement looks i recommend to you use index instead of columnName.
After calling the resultSet.executeQuery() you need to call the next() to pulling the records from db
after that you can call setXxx() provided by Java API
I am new to LINQ, and I wish to convert from one datatype to another in C#, as well as concatenate a string. How would I accomplish this?
For example, what would the SQL statement
SELECT IPv4 = CONVERT(varchar(3), IPv4_octet1) + '.' +
CONVERT(varchar(3), IPv4_octet2) + '.' +
CONVERT(varchar(3), IPv4_octet3) + '.' +
CONVERT(varchar(3), IPv4_octet4) FROM table;
be in LINQ? (The IPv4_octet's are stored as tinyints in the SQL table.)
In this case I suspect you could just write:
var query = data.Select(x => x.IpV4Octet1 + "." +
x.IpV4Octet2 + "." +
x.IpV4Octet3 + "." +
x.IpV4Octet4);
More generally you'd call ToString, e.g.:
// You wouldn't want to actually do this, but...
var query = data.Select(x => x.IpV4Octet1.ToString() + x.IpV4Octet4.ToString());
If you want more control, and you're not using the result in the rest of the query, you may well want to do the formatting on the .NET side - simply use AsEnumerable when you've selected all the information you want from the database, and then do the rest in LINQ to Objects. For example:
var query = db.Select(x => new { x.HostName, x.IpV4Octet1, x.IpV4Octet2,
x.IpV4Octet3, IpV4Octet4 })
.AsEnumerable() // Switch to LINQ to Objects for rest of query
.Select(x => new { x.HostName,
Address = string.Format("{0}.{1}.{2}.{3}"),
x.IpV4Octet1,
x.IpV4Octet2,
x.IpV4Octet3,
x.IpV4Octet4) });
try this:
string ipv4 = string.Join('.',octets.Select(o => o.ToString()).ToArray());
Using the query expression style, the let clause can be easily written. My question is how to use the dot notation style to write a let clause.
Essentially it's a Select (in most cases) which introduces a transparent identifier - via an anonymous type which encapsulates all the currently specified range variables. For example, this query:
string[] names = { "Jon", "Mark" };
var query = from name in names
let length = name.Length
where length > 3
select name + ": " + length;
is translated into something like this:
var query = names.Select(name => new { name, length = name.Length })
.Where(z => z.length > 3)
.Select(z => z.name + ": " z.length);