This question is locked. New answers and comments are not allowed.
Hi
I'm rather new to coding ASP.NET(C#), therefore I'd really appreciate some help for the following error:
I get an error when when the second linq is executed:
var protocolquery = from a in ScopeFactory.GetScope(ScopeID).Extent<Protocol>() |
select a; |
var scprotocoltmp = from sc in protocolquery |
where sc.SectionProtocols.Contains(section) |
select sc; |
if (scprotocoltmp.Count() > 0) |
{ |
var scprotocoltmp = from sc in protocolquery where sc.SectionProtocols.Contains(section) select sc;
if (scprotocoltmp.Count<Protocol>() > 0)
{
You can see it in the context in the images below.
SectionProtocols is a collection of Protocol, containing multiple Sections. (That's why I use "Contains", to search the List).
Thanks in advance for your help!
Regards
Deidn
Screenshot links:
http://yfrog.com/eqsiteijhttp://yfrog.com/5t95717762j
4 Answers, 1 is accepted
0
Accepted
Hi Roman,
Could you try uniting both queries into one. The query should give you the desired result set if you alter it like the following:
Best wishes,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Could you try uniting both queries into one. The query should give you the desired result set if you alter it like the following:
var protocolquery = from a in ScopeFactory.GetScope(ScopeID).Extent<Protocol>() |
where a.SectionProtocols.Contains(section) |
select a; |
Best wishes,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Roman
Top achievements
Rank 1
answered on 20 Jul 2009, 11:18 AM
That's it, you're right!
So does this mean that in case I use two queries I must somehow execute the previous IObjectScopeQuery before I'm able to further use it?
Thanks alot for your solution!
greetings
Roman
So does this mean that in case I use two queries I must somehow execute the previous IObjectScopeQuery before I'm able to further use it?
Thanks alot for your solution!
greetings
Roman
0
Accepted
Hello Roman,
It is preferable, but not always obligatory. You could split your query in two as well but the first should look like:
That way you could also execute the second query as you originally intended to.
Once again, I would suggest you using one query instead of splitting it to two.
Sincerely yours,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
It is preferable, but not always obligatory. You could split your query in two as well but the first should look like:
var protocolquery = ScopeFactory.GetScope(ScopeID).Extent<Protocol>(); |
Once again, I would suggest you using one query instead of splitting it to two.
Sincerely yours,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Roman
Top achievements
Rank 1
answered on 24 Jul 2009, 07:54 AM
Ok great, good to know, thanks a lot!
All the best
Roman
All the best
Roman