How to get value
-
New to Linq and C# so go easy please. How do I get the value from a query. I understand it returns a result set, but I just want to put a value into a local variable. var customer = from c in db.Customers where c.cid = 1 select c.CustomerName; string sCustomerName = ?; Thanks!
-
New to Linq and C# so go easy please. How do I get the value from a query. I understand it returns a result set, but I just want to put a value into a local variable. var customer = from c in db.Customers where c.cid = 1 select c.CustomerName; string sCustomerName = ?; Thanks!
try this, string customer = (from c in db.Customers where c.cid = 1 select c.CustomerName).FirstOrDefault(); assuming that cid is the unique. :)
Arun Jacob http://codepronet.blogspot.com/
-
try this, string customer = (from c in db.Customers where c.cid = 1 select c.CustomerName).FirstOrDefault(); assuming that cid is the unique. :)
Arun Jacob http://codepronet.blogspot.com/
Arun, Many Thanks! Did the trick. There are some great videos on the ASP.NET site and they were very helpful for getting started, just didn't address pulling specific values from the result set... Regards, Steve