- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: SQL problem
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "SQL problem"
Collapse
-
Yes my code was calling to be turned into the lambarda, but DP you must really have too much to time on your hands.
-
});public static IQueryable<TSource> WhereIn<TSource, TKey> (
this IQueryable<TSource> source1,
Expression<Func<TSource, TKey>> keySelector,
IEnumerable<TKey> source2) {
if (null == source1)
throw new ArgumentNullException ("source1");
if (null == keySelector)
throw new ArgumentNullException ("keySelector");
if (null == source2)
throw new ArgumentNullException ("source2");
Expression where = null;
foreach (TKey value in source2) {
Expression equal = Expression.Equal (
keySelector.Body,
Expression.Constant (value, typeof (TKey))
);
if (null == where)
where = equal;
else
where = Expression.OrElse (where, equal);
}
return source1.Where<TSource> (
Expression.Lambda<Func<TSource, bool>> (
where, keySelector.Parameters));
}
var britishJobsForBritishWorkersHaHa = (from u in db.Workers
select new { u.FirstName, u.LastName, u.Nationality }
).WhereIn (u => u.Nationality, new string[] { "Italian", "French", "Polish"
Fancy breaking this down line by line - maybe the less intelligent amongst us may get the joke
Leave a comment:
-
Yuk!Originally posted by FSM with Cheddar View PostI prefer an object orientated approach to the Jonny foreigner problem.
ForeignPoolOfWorkers pool = new ForeignPoolOfWorkers
ForeignPoolOfWorkers.Where(Columns.Nationality, Comparison.NotEqual, "british").Load
Code:public static IQueryable<TSource> WhereIn<TSource, TKey> ( this IQueryable<TSource> source1, Expression<Func<TSource, TKey>> keySelector, IEnumerable<TKey> source2) { if (null == source1) throw new ArgumentNullException ("source1"); if (null == keySelector) throw new ArgumentNullException ("keySelector"); if (null == source2) throw new ArgumentNullException ("source2"); Expression where = null; foreach (TKey value in source2) { Expression equal = Expression.Equal ( keySelector.Body, Expression.Constant (value, typeof (TKey)) ); if (null == where) where = equal; else where = Expression.OrElse (where, equal); } return source1.Where<TSource> ( Expression.Lambda<Func<TSource, bool>> ( where, keySelector.Parameters)); } var britishJobsForBritishWorkersHaHa = (from u in db.Workers select new { u.FirstName, u.LastName, u.Nationality } ).WhereIn (u => u.Nationality, new string[] { "Italian", "French", "Polish" });
Leave a comment:
-
I prefer an object orientated approach to the Jonny foreigner problem.
ForeignPoolOfWorkers pool = new ForeignPoolOfWorkers
ForeignPoolOfWorkers.Where(Columns.Nationality, Comparison.NotEqual, "british").Load
Leave a comment:
-
I think you'll findOriginally posted by Ruprect View PostTry this:
select *
from foreign_pool_of_workers
or
select *
from workers
where workers.nationality not in ("british")
NOTE: you cannot use a UNION in this query.
select worker
from foreign_pool_of_workers a
where a.nationality not in ('british','italian')
is more efficient
Leave a comment:
-
Try this:
select *
from foreign_pool_of_workers
or
select *
from workers
where workers.nationality not in ("british")
NOTE: you cannot use a UNION in this query.
Leave a comment:
-
SQL problem
trying to do a sql statement here, every time I key in total, it comes on the screen as Totale
whats going on, am I being xenophobic
Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- What is a tax-efficient salary for 2026/27 as a limited company director? Today 06:23
- Why the McCann Review is the latest failure of the Loan Charge scandal Mar 6 06:53
- What did Spring Statement 2026 say about mortgages? Mar 5 07:29
- Rachel Reeves overlooks contractors in ‘thin’ Spring Statement 2026 Mar 4 07:15
- Spring Statement 2026: chancellor’s full speech Mar 3 21:03
- Unlike today’s ‘boring’ Spring Statement 2026, Make Work Pay is transformative for contractors Mar 3 07:45
- Here’s Joint & Several Liability’s big misconception, and 5 key risks Mar 2 06:59
- How to run a limited company — efficiently: smarter profit strategies Feb 27 07:13
- IR35 & Mutuality of Obligation in 2026/27: Explainer for Contractors Feb 26 07:32
- Post Office hit with ‘crazy’ £104million HMRC bill for IR35 failings Feb 25 07:03

Leave a comment: