1
Reply

Function with var return type

Sasi Reddy

Sasi Reddy

Aug 13 2014 7:13 AM
683

I have a query like below
i need to implement this in function means
it should return PID ,PNAME to controller
how to write function in a class to return this.. 
  var subactivityid = (from records in db.PLANNING_DATASHEET
where planningid.Contains(records.PLANNING_ID)
select new { PID = records.PLANNING_ID, PNAME = records.SUBACTIVITY_MASTER.SUBACTIVITY_NAME }).ToList();

 var subactivityid = (from records in db.PLANNING_DATASHEET
                                    where planningid.Contains(records.PLANNING_ID)
                                    select new { PID = records.PLANNING_ID, PNAME = records.SUBACTIVITY_MASTER.SUBACTIVITY_NAME }).ToList();


          ViewBag.SUBACTIVITY_ID = new SelectList(subactivityid, "PID", "PNAME");

I am binding dropdown like above.

but i need like this instead of linq
var subactivityid=far.getSubactivity(Planningid);



Answers (1)