开发者

Dynamic parameters for where clause in a typed dataset possible?

开发者 https://www.devze.com 2022-12-20 13:51 出处:网络
The normal ASP.NET TableAdapters are good for simple where clauses, for example - \"where city = @city and state = @state and zip = @zip\"

The normal ASP.NET TableAdapters are good for simple where clauses, for example - "where city = @city and state = @state and zip = @zip"

But how do I design a DAL that allows me to use any combination of the parameters - "search only by city" or "search by zip and state" or "search by city and state".....or even more complex "search by zip but if @zip is开发者_JAVA百科 null then search by city"....

How can I design a DAL that supports such dynamic where conditions? Are typed datasets with table adapters the best approach? Currently, I'm just using dynamic SQL queries with normal datasets and I'm trying to convert it into some sort of strongly typed DAL.


It sounds to me like you might want to review Dynamic LINQ. It can be helpful when such dynamic conditions exist. I have found the Code Samples here to be very helpful.

HTH, Sid

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号