Hi everyone. I'm using Linq queries.
Here's an example of the address search expression for an individual address
private IMonad<Option, Expression<Func<Address, bool>>>
addressExpressionByContent(
IDictionary<string, Direction> sortedDirections, IDictionary<
string, StreetType> sortedStreetTypes,
HansenAcctVw hansenAcctvW) {
var streetNameOption = hansenAcctvW.getStreetname(
sortedDirections);
var houseNumberOption = hansenAcctvW.getHouseNumber();
var subdesignationOption = hansenAcctvW.getSubdesignation();
var postalCodeOption = hansenAcctvW.getFormattedPostalCode();
var predirectionOption = hansenAcctvW.getPredirection();
var postdirectionOption = hansenAcctvW.getPostdirection(
sortedDirections);
var suffixOption = hansenAcctvW.getSuffix(sortedDirections,
sortedStreetTypes);
var initialAddressExpressionOption =
streetNameOption.bind(streetName
=>
houseNumberOption.bind(houseNumber =>
suffixOption.map<Expression<Func<Address, bool>>>(suffix
=> address =>
address.CASTNAME == streetName &&
address.CASTNO == houseNumber &&
address.CASUFFIX == suffix)));
var predirectionLookup = predirectionOption.map<Expression<Func<
Address, bool>>>(predirection =>
address => address.CAPREDIR == predirection).
getValueOrDefault(() =>
address => address.CAPREDIR == null || address.CAPREDIR
== " ");
var postdirectionLookup = postdirectionOption.map<Expression<
Func<Address, bool>>>(postdirection =>
address => address.CAPOSTDIR == postdirection).
getValueOrDefault(() =>
address => address.CAPOSTDIR == null || address.CAPOSTDIR
== " ");
var subdesignationLookup = subdesignationOption.map<Expression<
Func<Address, bool>>>(subdesignation =>
address => address.CASTSUB == subdesignation).
getValueOrDefault(() =>
address => address.CASTSUB == null || address.CASTSUB == "
");
var postalCodeLookup = postalCodeOption.map<Expression<Func<
Address, bool>>>(postalCode =>
address => address.CAPOSTCODE == postalCode).
getValueOrDefault(() =>
address => address.CAPOSTCODE == null || address.CAPOSTCODE
== " ");
Expression<Func<Address, bool>> cityLookup = address =>
address.CACITY
== "REGINA";
Expression<Func<Address, bool>> addressType = address => address
.CAADDRTYPE == "A";
Expression<Func<Address, bool>> addressKeyNot1 = address =>
address.ADDRKEY != 1;
var otherExpressionList = new [] {
predirectionLookup, postdirectionLookup,
subdesignationLookup, postalCodeLookup, cityLookup,
addressType, addressKeyNot1
};
return initialAddressExpressionOption.map(initialAddressExpression
=> {
var foldedExpressionBody = otherExpressionList.Aggregate(
initialAddressExpression.Body, (u, v) =>
Expression.AndAlso(u, v.Body));
return Expression.Lambda<Func<Address, bool>>(
foldedExpressionBody, initialAddressExpression.Parameters[0]);
});
}
On Thursday, December 4, 2014 10:43:34 PM UTC-6, Ricardo Peres wrote:
>
> Are you using parameters or are you putting query values directly in the
> query? For example, in HQL, do you have: CreateQuery("select s from
> Something s where s.SomeProperty = 1") or CreateQuery("select s from
> Something where s.SomeProperty = :p").SetParameter("p", 1)?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.