Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
LinqToSQL I am having a problem to select a column from a group, below is my query

C#
  var qry = (from i in INTERNETDATAs 
	join c in COVERS on Convert.ToInt32(i.COVERTYPE) equals c.COV_TYPE
	join b in BENEFITS on c.COVERID equals b.COVERID
	join p in POLICies on i.REFERENCENO equals p.BACS_POLNO into grp
		where  i.DATELOADED >= new DateTime(2013,1,1)
		&& i.DATELOADED < new DateTime(2014,1,1)
		&& i.CAMPAIGNTYPE == "1"
		&& c.COVERTYPEID == 17063789
	orderby i.DOB	
	select new
	{
		i.ID,
		Campaign = i.CAMPAIGNTYPE,
		Title = i.TITLE,
		Dob = i.DOB,
		Accepted = i.ACCEPTED,
		BankLetter = i.BANKLETTER,
		//p.STATUS,
		//grp.STATUS,
		MonthlyPremium = c.MONTHLYPREMIUM,
		BenefitAmount = b.BENEFITAMOUNT,
		Description = b.BENEFITDESCRIPTION
	}
	).DefaultIfEmpty();			
qry.Dump();

This query gives expected result but I alos need a STATUS column from POLICies table, when I remove the comment for //p.STATUS or //grp.STATUS I get following Error as below

**Cannot execute text selection: 'System.Collections.Generic.IEnumerable<linqpad.user.policy>' does not contain a definition for 'STATUS' and no extension method 'STATUS' accepting a first argument of type 'System.Collections.Generic.IEnumerable<linqpad.user.policy>' could be found (press F4 to add a using directive or assembly reference)**

If any one can please help me out with this as I have tried everything I can.

Thanks
Posted
Updated 29-Aug-13 5:19am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900