Solved

linq to sql query for extract email which is not in string array

Posted on 2008-06-21
2
212 Views
Last Modified: 2013-11-26
i have array like

string[] email=new string[]{"aa@aa.com","aa1@aa.com"}

now i need to extract all record which does not contail this emails.

0
Comment
Question by:jbajaj
[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
2 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21836825
I don't understand the question.  I see that you have an array of emails - are you using this to search through a DB that has an email field and you want the records that are *not* in the array?

For example if your array is { "a@email.com", "b@email.com" }

and you table is:
EMAIL
a@email.com
b@email.com
c@email.com
d@email.com

You want the query to return c@email and d@email.com?
0
 
LVL 21

Accepted Solution

by:
naspinski earned 500 total points
ID: 21836848
If that is the case, this query will return all the records that the [email] column does not contain an email that is inside the array:
var query = from p in db.items where !email.Contains(p.EMAIL) select p;
 
//  'EMAIL' is a column in my table which is named 'items'
//  'db' is my DataContext object

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

630 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