Solved

how to check value if it is between two values in linq?

Posted on 2010-11-20
3
535 Views
Last Modified: 2013-12-17
hi,

I was trying to check value if it is between two values from xml file, so how to perform between "something" and "something else" using linq?


here is my try
var countries = from country in xmlDoc.Descendants("IpCountries")
                               where Dot2LongIP.ToString() between country.Element("beginningIp").Value and country.Element("endingIp").Value
                               select new
                               {
                                   hostIPAddress = country.Element("beginningIp").Value,
                                   hostName = country.Element("endingIp").Value,
                                   hostLocation = country.Element("countryCC").Value,
                                   hostBrowserType = country.Element("countryCCC").Value,
                                   hostBrowserVersion = country.Element("country").Value,
                               };

Open in new window

0
Comment
Question by:njgroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 34179933
Try this:
var countries = from country in xmlDoc.Descendants("IpCountries")
                               let longIp = Dot2LongIP
                               where longIP >= Convert.ToInt64(country.Element("beginningIp").Value) && longIP <= Convert.ToInt64(country.Element("endingIp").Value)
                               select new
                               {
                                   hostIPAddress = country.Element("beginningIp").Value,
                                   hostName = country.Element("endingIp").Value,
                                   hostLocation = country.Element("countryCC").Value,
                                   hostBrowserType = country.Element("countryCCC").Value,
                                   hostBrowserVersion = country.Element("country").Value,
                               };

Open in new window

0
 

Author Closing Comment

by:njgroup
ID: 34180130
thanks very much,

I was looking for something better than A grade to assign :))

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34180519
NP. Glad to help  :)
0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question