score:0

As mentioned, Linq does not play well with dynamic. Linq makes heavy use of extension methods, which much be bound at compile-time and thus you can't use dynamic since it defers all binding to run-time.

If you have two datasets that do not have a common base type or interface, but have the same entity types (by name at least), then you'll need two overloads. You might be able to refactor part of it to improve reuse:

private void CallCustomerCodeDynamically(CustmoerEntities1 customerEntities)
{
    var customerCode= from customer in customerEntities.CustomerInfoes
                   orderby customer.CustomerCode ascending
                   select customer.CustomerCode;

    BindCodes(customerCode);
}


private void CallCustomerCodeDynamically(CustmoerEntities2 customerEntities)
{
    var customerCode= from customer in customerEntities.CustomerInfoes
                   orderby customer.CustomerCode ascending
                   select customer.CustomerCode;

    BindCodes(customerCode);
}

private void BindCodes(IEnumerable<string> customerCode)
{
    ddlCustomerCode.DataSource = customerCode;
    ddlCustomerCode.DataBind();
}

Related Query

More Query from same tag