LINQ query on dotnet code and how concat will work here - asp.net

i am not a dot net programmer but need to migrate dotnet code to java .having issue understanding this follwing piece
Lets say specificTermical and ShipTo have latitutde property with different value so what happends when we use concat what will be the final value eg. 23.10+43.10 or something else
List<OrderDispatchItemDTO> locations =(List<OrderDispatchItemDTO>) msg.Details.Select(x => x.SpecificTerminal).Concat(msg.Details.Select(x => x.ShipTo));

The line of code that you provide returns a List of OrderDispatchItemDTO objects, that contains the values of both the SpecificTerminal and ShipTo properties of the Details objects.
It doesn't make any kind of calculation between the values of SpecificTerminal and ShipTo properties; it only adds both of them in a common list.
More detailed:
The Select method returns a new IEnumerable of the selected objects
And the Concat method concatenates the second collection into the first.

Concat is a string method. When you concatenate "23.10" and "43.10", it gives "23.1043.10". Therefore combining the two strings together.
To do any calculation in c#, you have to convert from strings data types to other mathematical data type that fits the say.
You may convert those two values to float and add them as shown below:
Float sum = Convert.ToFloat(23.10) + Convert.ToFloat(43.10);

Related

Custom sorting issue in MarkLogic?

xquery version "1.0-ml";
declare function local:sortit(){
for $i in ('a','e','f','b','d','c')
order by $i
return
element Result{
element N{1},
element File{$i}
}
};
local:sortit()
the above code is sample, I need the data in this format. This sorting function is used multiple places, and I need only element N data some places and only File element data at other places.
But the moment I use the local:sortit()//File. It removes the sorting order and gives the random output. Please let me know what is the best way to do this or how to handle it.
All these data in File element is calculated and comes from multiple files, after doing all the joins and calculation, it will be formed as XML with many elements in it. So sorting using index and all is not possible here. Only order by clause can be used.
XPath expressions are always returned in document order.
You lose the sorting when you apply an XPath to the sequence returned from that function call.
If you want to select only the File in sorted order, try using the simple mapping operator !, and then plucking the F element from the item as you are mapping each item in the sequence:
local:sortit() ! File
Or, if you like typing, you can use a FLWOR to iterate over the sequence and return the File:
for $result in local:sortit()
return $result/File

Why fn:substring-after Xquery function could not be used inside ML TDE

In my ML db, we have documents with distributor code like 'DIST:5012' (DIST:XXXX) XXXX is a four-digit number.
currently, in my TDE, the below code works well.
However instead of concat all the raw distributor codes, I want to simply concat the number part only. I used the fn:substring-after XQuery function. However, it won't work. It won't show that distributorCode column in the SQL View anymore. (Below code does not work.)
What is wrong? How to fix that?
Both fn:substring-after and fn:string-join is in TDE Dialect page.
https://docs.marklogic.com/9.0/guide/app-dev/TDE#id_99178
substring-after() expects a single string as input, not a sequence of strings.
To demonstrate, this will not work:
let $dist := ("DIST:5012", "DIST:5013")
return substring-after($dist, "DIST:")
This will:
for $dist in ("DIST:5012", "DIST:5013")
return substring-after($dist, "DIST:")
I need to double check what XPath expressions will work in a DTE, you might be able to change it to apply the substring-after() function in the last step:
fn:string-join( distributors/distributor/urn/substring-after(., 'DIST:'), ';')

Gatling - Split Value In Check

I have a HTML element from a HTTP request like so:
<input type="radio" data-trip="0" id="fareRadioId_" name="pricefare" value="H15CNGE~SHATSA~220420150955~3332|H15CNGE~TSASHA~270420150715~338" class="pricefare" data-toggle="radio" checked="checked">
I'm used to pulling a value from a CSS select like so:
.check(css("input#fareRadioId_0.select_departure", "value").saveAs("departSellKey"))
But after I've selected the value in the element above which is "H15CNGE~SHATSA~220420150955~3332|H15CNGE~TSASHA~270420150715~338", I want to split it in to parts, with the split character being "|", and save the two parts in to session with 2 different names. Is this possible?
I've pretty new to Gatling and Scala so this is a little above my head at the moment. Any help would be greatly appreciated.
I'm not sure if you'll be able to save the two parts with different names, but it's fairly easy to perform the split and store the result as a Seq, after which you can access it with indexes etc.
What you need to do is insert a suitable transformer into your check:
.check(css("...").transform(_.split('|').toSeq).saveAs("sellKeys"))
This takes the String from the css() expression, does a split() on it (which creates an Array[String]) and then converts it to a Seq because they're nicer to work with :-)
The Seq is then saved into sellKeys, so later on you can do things like (silly example):
.exec( session => {
val keys = session("sellKeys").as[Seq[String]]
println(s"keys are ${keys.mkString(" and ")}")
println(s"the first key is ${keys.head}")
session
}
)
Output:
keys are H15CNGE~SHATSA~220420150955~3332 and H15CNGE~TSASHA~270420150715~338
the first key is H15CNGE~SHATSA~220420150955~3332

Acquiring all nodes that have ids beginning with "ABC"

I'm attempting to scrape a page that has about 10 columns using Ruby and Nokogiri, with most of the columns being pretty straightforward by having unique class names. However, some of them have class ids that seem to have long number strings appended to what would be the standard class name.
For example, gametimes are all picked up with .eventLine-time, team names with .team-name, but this particular one has, for example:
<div class="eventLine-book-value" id="eventLineOpener-118079-19-1522-1">-3 -120</div>
.eventLine-book-value is not specific to this column, so it's not useful. The 13 digits are different for every game, and trying something like:
def nodes_by_selector(filename,selector)
file = open(filename)
doc = Nokogiri::HTML(file)
doc.css(^selector)
end
Has left me with errors. I've seen ^ and ~ be used in other languages, but I'm new to this and I have tried searching for ways to pick up all data under id=eventLineOpener-XXXX to no avail.
To pick up all data under id=eventLineOpener-XXXX, you need to pass 'div[id*=eventLineOpener]' as the selector:
def nodes_by_selector(filename,selector)
file = open(filename)
doc = Nokogiri::HTML(file)
doc.css(selector) #doc.css('div[id*=eventLineOpener]')
end
The above method will return you an array of Nokogiri::XML::Element objects having id=eventLineOpener-XXXX.
Further, to extract the content of each of these Nokogiri::XML::Element objects, you need to iterate over each of these objects and use the text method on those objects. For example:
doc.css('div[id*=eventLineOpener]')[0].text

Programmatically getting a list of variables

Is it possible to get a list of declared variables with a VimL (aka VimScript) expression? I'd like to get the same set of values that will be presented for a command using -complete=expression. The goal is to augment that list for use in a user-defined command completion function.
You can use g: as a dictionary that holds all global variables, so:
let globals = keys(g:)
will give you all the names. The same applies to the other scopes: b:, s:, w:, etc. See :help internal-variables for the complete list.
You can get something similar using keys of g:, b:, t:, w: and v: dictionaries, but beware of the following facts:
There is no equivalent to this dictionaries if you want to complete options.
Some variables like count (but not g:count or l:count), b:changedtick and, maybe, others are not present in this dictionaries.
Some vim hacker may add key ### to dictionary g:, but it won't make expression g:### valid variable name (but adding 000 there will). Though g:["###"] will be a valid expression.

Resources