Here's one possible way: from c in Coupons from cs in ((from c in coupons where c. Published == false select c).Distinct() ). Take(10) where cs.ID == c.
ID select c Keep in mind that LINQ creates a strongly-typed data set, so an IN statement has no general equivalent. I understand trying to keep the SQL tight, but LINQ may not be the best answer for this. If you are using MS SQL Server (not SQL Server Compact) you might want to consider doing this as a Stored Procedure.
Using MercurioJ's slightly buggy response, in combination with another SO suggested random row solution my solution was: var result3 = (from c in _dataContext. Coupons from cs in ((from c1 in _dataContext. Coupons where c1.
IsPublished == false select c1).Distinct() ). Take(10) where cs. CouponId == c.
CouponId orderby _dataContext.NewId() select c). Take(1).
I have the following SQL query, which I'm struggling to convert to LINQ. Purpose: Get the top 10 coupons from the table, ordered by the date they expire (i.e. List the ones that are about to expire first) and then randomly choosing one of those for publication.
Notes: Because of the way the database is structured, there maybe duplicate Codes in the Coupon table. Therefore, I am using a GROUP BY to enforce distinction, because I can't use DISTINCT in the sub select query (which I think is correct). The SQL query works.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.