In my current project, I am using SQL CE. Since it does not have support for stored procedures, I have to write sql queries inside the repository.
Option 1:
StringBuilder query = new StringBuilder(); query.Append("SELECT"); query.Append(" c.CUSTOMER_ID,"); query.Append(" COALESCE (c.FIRST_NAME, '') + ' ' + COALESCE (c.LAST_NAME, '') AS FULL_NAME"); query.Append(" ct.NAME as CUSTOMER_TYPE"); query.Append("FROM "); query.Append(" CT_CUSTOMER_TYPE AS ct INNER JOIN CUSTOMER AS c ON ct.CUSTOMER_TYPE_ID = c.CUSTOMER_TYPE_ID");
Option 2:
string query = "SELECT c.CUSTOMER_ID, COALESCE (c.FIRST_NAME, '') + ' ' + COALESCE (c.LAST_NAME, '') AS FULL_NAME, ct.NAME as CUSTOMER_TYPE FROM CT_CUSTOMER_TYPE AS ct INNER JOIN CUSTOMER AS c ON ct.CUSTOMER_TYPE_ID = c.CUSTOMER_TYPE_ID";
Option 1 seems more readable, especially when I have 10+ tables in the join, but option 2 is faster.
Which option should I accept and what is the best in this case?
c # coding-style
šljaker
source share