I have two unrelated questions which I am hoping someone else has experience
with. The documentation on these areas is limited and I am not finding good
examples online.
Question One: <update/> statements
I have structures with nullable data members which match the actual data
classes I use for holding data. The purpose of the structures is to allow a
developer to instantiate the structure and fill in (i.e. give a non-null
value to) any property which they want to include in the where clause. This
class is defined as the <update parameterClass/>. In the case of an
<update/>, I also want to be able to pass in a set of values in the form of
a class. However, I don't see any attributes that will allow me to pass in
an argumentClass (with values for the SET column = property) and a
parameterClass (for the WHERE column = property). Am I missing something
here?
Question Two: <dynamic/> where clause
Here again I use the "Parameter structure" described above, but I am having
trouble getting the right combination of XML elements put together to do
what I want. My goal here is to be able to do the following with one
<select/> statement:
(A) If no parameter is provided (parameterClass = null), then I want to just
have a SELECT-FROM statement with no WHERE clause at all.
(B) If a parameterClass is provided and has at least one property that is
not null, then I want to evaluate each of the property values in the
parameterClass and, if that property is not null, I want to add a WHERE
condition for that specific property. Here's what my <select><dynamic>
statement looks like today:
<select id="SelectActionLevel" parameterClass="ActionLevelParams"
resultMap="ActionLevelResult" listClass="ActionLevelList">
SELECT ACTION_LEVEL_ID,
NAME,
DESCRIPTION
FROM ACTION_LEVEL_T
<dynamic prepend="WHERE">
<isParameterPresent>
<isNotNull prepend="AND"
property="ActionLevelId">ACTION_LEVEL_ID = #ActionLevelId#</isNotNull>
<isNotNull prepend="AND" property="Name">NAME =
#Name#</isNotNull>
<isNotNull prepend="AND" property="Description">DESCRIPTION
= #Description#</isNotNull>
</isParameterPresent>
</dynamic>
</select>
Does anyone have any advise on how I can modify this to do what I am looking
for above?
Thanks for your help!
Tony