readRelationshipFormat
package
static if(hasMsSql)
enum readRelationshipFormat =
q{
if (relationship.sql)
{
model.%1$s = (getMsSqlAdapter!%3$s).readMany(relationship.sql, null);
}
else if (relationship.members)
{
auto params = getParams();
string[] whereClause = [];
static foreach (memberLocal,memberRemote; relationship.members)
{
mixin("whereClause ~= \"[" ~ memberRemote ~ "] = ?\";");
mixin("params[\"" ~ memberLocal ~ "\"] = model." ~ memberLocal ~ ";");
}
import std.array : join;
model.%1$s = (getMsSqlAdapter!%3$s).readMany("SELECT * FROM [@table] WHERE " ~ whereClause.join(" AND "), params);
}
};
The format for reading relationships.