c# - QueryOver: Dynamically adding IsLike in Where clause -
i've queryover select log records logs name starts d or f (using wildcards).
conv.innertransaction.session.queryover<log>() .where(l => l.datetime > _datetime) .and( l => l.name.islike("d%") || l.name.islike("f%") )
instead name searching dynamically using values list. how can done?
i've tried like:
var query = conv.innertransaction.session.queryover<log>() .where(l => l.datetime > _datetime); foreach (var name in _names) { query = query.and(l => l.name.islike(name)); }
but result in multiple , statements each name in list, whereas need or.
have tried disjunction
? had similar requirement once, had use conjunction
instead. disjunction
or
multiple conditions together.
var disjunction = new disjunction(); var query = session.queryover<log>().where(l => l.datetime > _datetime); foreach (var name in _names) { disjunction.add(restrictions.on<log>(log => log.name).islike(name)); } var queryresult = query.where(disjunction).list<log>();
Comments
Post a Comment