I am using this code to search data in SQL Server. But the result is return to list, what should I return it to get one row only? Means I want to use textblock binding to get a record without using listbox template..
public List<Customer> FindProfile(string custemail)
{
var findprofile = from r in cust.Customers where r.CustEmail == custemail select r;
return findprofile.ToList();
}
public List<Customer> GetProfileData()
{
var profiledata = from r in cust.Customers
select r;
return profiledata.Take(5).ToList();
}
public pgProfile()
{
InitializeComponent();
proxy.FindProfileCompleted += new EventHandler<FindProfileCompletedEventArgs>(proxy_FindProfileCompleted);
proxy.FindProfileAsync(custemail);
}
void proxy_FindProfileCompleted(object sender, FindProfileCompletedEventArgs e)
{
ListBox1.ItemsSource = e.Result;
}
Can’t you just use
.First()or.FirstOrDefault()on the list of customers that gets returned??