export const CONTACT_COLUMNS = ` id, entity_id AS entityId, contacttype AS contactType, contact, sort `; export const LIST_BY_ENTITY = ` SELECT ${CONTACT_COLUMNS} FROM entitycontact WHERE entity_id = @entityId ORDER BY sort ASC, id ASC `; export const GET_BY_ENTITY_AND_ID = ` SELECT ${CONTACT_COLUMNS} FROM entitycontact WHERE id = @id AND entity_id = @entityId `; export const GET_NEXT_SORT = ` SELECT ISNULL(MAX(sort), -1) + 1 AS sort FROM entitycontact WHERE entity_id = @entityId `; export const CREATE = ` INSERT INTO entitycontact (entity_id, contacttype, contact, sort) OUTPUT INSERTED.id, INSERTED.entity_id AS entityId, INSERTED.contacttype AS contactType, INSERTED.contact, INSERTED.sort VALUES (@entityId, @contactType, @contact, @sort) `; export const UPDATE = ` UPDATE entitycontact SET contacttype = @contactType, contact = @contact, sort = @sort OUTPUT INSERTED.id, INSERTED.entity_id AS entityId, INSERTED.contacttype AS contactType, INSERTED.contact, INSERTED.sort WHERE id = @id AND entity_id = @entityId `; export const DELETE_BY_ENTITY_AND_ID = ` DELETE FROM entitycontact WHERE id = @id AND entity_id = @entityId `;