I have solved this one myself. It's all about understanding the GroupBy Extension:
public static IQueryable<deliverymethod> QueryByProductIds(
int[] productIds,
DataContext1 db)
{
return Query(db)
.Join(
productdeliverymethods.QueryByProductIds(productIds, db),
a => a.deliverymethod_id,
ab => ab.deliverymethod_id,
(a, ab) => a)
.GroupBy(
a => a,
(key, g) => new
{
Key = key,
Count = g.Count()
})
.Where(g => g.Count == productIds.Length)
.Select(g => g.Key);
</deliverymethod>
In fact, it worked so well that I have made an extention method
public static IQueryable IntersectAll<t>(this IQueryable<t> query, int count)
{
return query
.GroupBy(
q => q,
(key, g) => new
{
Key = key,
Count = g.Count()
})
.Where(g => g.Count == count)
.Select(g => g.Key);
}
public static IQueryable<deliverymethod> QueryByProductIds(
int[] productIds,
DataContext1 db)
{
return Query(db)
.Join(
productdeliverymethods.QueryByProductIds(productIds, db),
a => a.deliverymethod_id,
ab => ab.deliverymethod_id,
(a, ab) => a)
.IntersectAll(productIds.Length);
</deliverymethod></t></t>
Hope someone finds this useful. I am quite proud ^_^