Your code doesn't make any sense at all. Oh, it also leaks resources.
1) You're creating a new DbContext (CustomerEntities), never using it and never disposing of it. This is your leak.
2) You're creating a IQueryable, called "customer", never using it then throwing it out.
3) The query you do run is on this "CustomerTbl", whatever that it is, where you're searching for a RefNumber inside of a customer name. Why would a "RefNumber" show up in a customer name? That doesn't make any sense.
4) You're not returning a single customer. You're returning a collection of customers. In your case, you may be returning a collection of Customers that only has one Customer in it.
5) You never create a view model object to pass to your view. You're passing a collection of database objects to your view. This is bad practice. The View Model class you create should contain only the data that your page is going to show/edit and the supporting data to accomplish that edit.
The controller is generally responsible for managing the view the client sees and uses. Arguably, it can be said that it is also responsible for translating between the view models and database models.
Generally, your controller code would look something like this:
public ActionResult Mycontroller(string RefNumber)
{
using (var context = new CustomerEntities())
{
var customers = (from c in context.CustomerTbl
where c.customerName.Contains(RefNumber)
select new CustomerViewModel()
{
CustomerId = c.CustomerId,
CustomerName = c.customerName
}).ToList();
}
return View("_Customer", customers);
}</customerviewmodel>