Monday, April 14, 2008

NetTiers Find method

NetTiers will build methods for normal CRUD as well as anything they can determine. For example, if you have a table with 1PK and 2FKs, the template with build a method for select where the IN params are the two FKs. Great! I probably need that. But things get a little weird when I need to search. For example, I have a user's table and I want to be able to return results for all users that are like a searchterm. How about all user's like Dina. In T-SQL, I usually would have a where clause " UserName like '%@UserName%'. Works for me.

NetTiers has a Find method for each table. When creating a find proc, it's hard to determine which columns you would want to search through. NetTiers discovery does a bit of assuming that the first column (after the PK/FK columns) is THE main data column (such as a name). But that takes some forethought in terms of table creation. The NetTiers find method comes in two varieties: one with sql params in the NetTiers format and one with a SQL where clause. The NetTiers template should let you turn off this second way but it doesn't. Inside the stored procs that NetTiers creates, they put the where clause together. This makes me a bit nervous. I don't want a user entering something in a search textbox and have it passed to build a SQL query on the fly.

I'm going to write my own custom search proc sing the NetTiers naming conventions so I get a custom Find Method from NetTiers. I know what columns I want to search through on the Table but I also want to get my results in two line of c# code via NetTiers layer.