none
Lists in linq RRS feed

  • Question

  • I am trying to pull from a datrabase a list which should only have 1 element. The GetSubscrribers(Ilist<int> SubscriberId) command is meant to fins a certain entry.

    var Subscribers=Data.Subscribers.ToList().Select(s => new Domain Sunscriber() {Id=s.Id,SubscriberName=s.SubscriberName...etc}).AsQueryable().ToLIst();

    How can I insert a 'where SubscriberID==Id' into that command?

    Thursday, March 8, 2012 6:20 PM

Answers

  • Try the below:

    var Subscribers = (from s in Data.Subscribers.Where(su => SubscriberID == Id)
    		  select new
    		    {
    			Id=s.Id,
    			SubscriberName=s.SubscriberName,
    			...etc
    		    }).ToList();

    Friday, March 9, 2012 10:07 AM