Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

15 Experts available now in Live!

Get 1:1 Help Now