I have a table that contains a list of pagehits that I would like to analyse. One of the fields is URL
that unsurprisingly contains the URL of the pagehit. This includes any query strings, eg http://foo.bar/default.aspx?test=1234
I would like to strip out the query strings from this table for my analysis and thought the following simple string split would work:
var pageHits = from p in context.Pagehits
let URL = p.URL.Split('?')[0]
select p;
However I get the error: The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities.
Given the table is fairly hefty whats the best way to return the URL without the query strings?
EDIT: I can get it work if i call .ToList
but that seems computationally excessive
You can try something like this
var pageHits = from p in list
select p.Substring(0,p.IndexOf('?');
I made a List of strings which contains urls only to check if it works (my "list" in the code)
var pageHits = from p in context.Pagehits
select p;
pageHits.ToList().ForEach(p =>
{
p.Url = p.Url.Split('?')[0];
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.