Solved

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

Posted on 2008-06-21
2
196 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# HTTP GET method sample code 3 55
What namespace do I need to import? 2 25
How to join on ID, with prefix? 15 58
location of a form 2 10
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now