Click here to Skip to main content
15,908,906 members
Home / Discussions / C#
   

C#

 
JokeRe: I want to draw a empty triangular arrow Pin
Christian Graus27-Sep-05 15:39
protectorChristian Graus27-Sep-05 15:39 
GeneralRe: I want to draw a empty triangular arrow Pin
dreamwinter27-Sep-05 22:04
dreamwinter27-Sep-05 22:04 
GeneralRe: I want to draw a empty triangular arrow Pin
Christian Graus28-Sep-05 1:09
protectorChristian Graus28-Sep-05 1:09 
QuestionCrazy question about reflection Pin
Colin Angus Mackay27-Sep-05 11:52
Colin Angus Mackay27-Sep-05 11:52 
AnswerRe: Crazy question about reflection Pin
Guffa28-Sep-05 0:28
Guffa28-Sep-05 0:28 
GeneralRe: Crazy question about reflection Pin
Colin Angus Mackay28-Sep-05 2:27
Colin Angus Mackay28-Sep-05 2:27 
GeneralRe: Crazy question about reflection Pin
Guffa28-Sep-05 9:25
Guffa28-Sep-05 9:25 
GeneralRe: Crazy question about reflection Pin
Colin Angus Mackay28-Sep-05 12:36
Colin Angus Mackay28-Sep-05 12:36 
I was just looking for a way to transfer the parameters passed into the method to parameters to the Stored Procedure. The method is just a proxy to the stored procedure, everything is passed straight through with no real processing. This is not coupling the layers together. It is using the surrogate pattern (see Design Patterns: Elements of Reusable Object Oriented Software by Gamma et al.)

For example at the moment I might have a method in my DAO assembly that looks like this:
public bool InsertData(int id, string name, int someValue)
{
   SqlParameter[] spParams = new SqlParameter[3];
   spParams[0] = new SqlParameter("@id", id);
   spParams[1] = new SqlParameter("@name", name);
   spParams[2] = new SqlParameter("@someValue", someValue);
 			
   int result = (int)SqlHelper.ExecuteScalar(ConnectionString, 
      CommandType.StoredProcedure, "InsertData", spParams);
 
   return result==1;
}


As you can see all that is happening is that there is a stored procedure with exactly the same signature (only in SQL) and my DAO class is acting as a proxy or surrogate for the Stored Procedure so that I can layer my application properly and don't have lots of SQL calls dispersed randomly throughout my code.

All I wanted was to see if there was some automated mechanism to transfer the parameter values passed into the method to Stored Procedure without having to manually build up a SqlParameter array.

Now, obviously, if there isn't such a mechanism then that's fine - I just have a bit more work to do for each Stored Procedure.


Guffa wrote:
Well, the information you could get from the method parameters is just not enough to create the parameters

As you can see from my example above, all I need is the name of the parameter and its value. You don't NEED to put in other information.

Guffa wrote:
a string doesn't have a specified maximum length, but a varchar field in the database does.

That isn't of concern the business rules prevent bad data getting through. The Stored Procedures also do their own sanity checks. The EXECUTE permissions on the Stored Procedures will only allow certain users to access them. Users cannot access the tables directly and must go through stored procedures.

As you can see I have thought a lot about the design of the application to ensure that it is properly decoupled and that bad data gets stopped as early as possible, but there additional checks in place to catch anything bad that might get through. I am also constantly refactoring the application to improve the ability to maintain it and improve security.

Are you happy yet that I am actually a competent developer and that I just wanted my original question answered rather than enter into a discussion about my abilities to design an application properly?


My: Blog | Photos

"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious


GeneralRe: Crazy question about reflection Pin
Guffa29-Sep-05 1:06
Guffa29-Sep-05 1:06 
QuestionBroadcast a Windows Message (C#) Pin
emarborg27-Sep-05 11:27
emarborg27-Sep-05 11:27 
AnswerRe: Broadcast a Windows Message (C#) Pin
Dave Kreskowiak27-Sep-05 12:30
mveDave Kreskowiak27-Sep-05 12:30 
QuestionDataGridView.ColumnHeadersDefaultCellStyle Pin
Drew McGhie27-Sep-05 10:10
Drew McGhie27-Sep-05 10:10 
QuestionWierd serialization behaviour Pin
jolofsson27-Sep-05 9:43
jolofsson27-Sep-05 9:43 
AnswerRe: Wierd serialization behaviour Pin
turbochimp28-Sep-05 2:08
turbochimp28-Sep-05 2:08 
QuestionEdit .msi database programatically Pin
Asad Hussain27-Sep-05 9:07
Asad Hussain27-Sep-05 9:07 
AnswerRe: Edit .msi database programatically Pin
Christian Graus27-Sep-05 9:25
protectorChristian Graus27-Sep-05 9:25 
AnswerRe: Edit .msi database programatically Pin
Dave Kreskowiak27-Sep-05 12:28
mveDave Kreskowiak27-Sep-05 12:28 
AnswerRe: Edit .msi database programatically Pin
Sean Michael Murphy28-Sep-05 8:35
Sean Michael Murphy28-Sep-05 8:35 
QuestionAccess XML element directly Pin
Seraphin27-Sep-05 6:31
Seraphin27-Sep-05 6:31 
AnswerRe: Access XML element directly Pin
Gavin Jeffrey27-Sep-05 8:22
Gavin Jeffrey27-Sep-05 8:22 
QuestionListView in details view with values... Pin
Niklas Ulvinge27-Sep-05 6:11
Niklas Ulvinge27-Sep-05 6:11 
QuestionSOAP Web Service in Win Forms Application? Pin
jkersch27-Sep-05 6:01
jkersch27-Sep-05 6:01 
AnswerRe: SOAP Web Service in Win Forms Application? Pin
Heath Stewart27-Sep-05 6:24
protectorHeath Stewart27-Sep-05 6:24 
QuestionOutOfMemoryException when allocating large buffer Pin
mkomsa27-Sep-05 5:46
mkomsa27-Sep-05 5:46 
AnswerRe: OutOfMemoryException when allocating large buffer Pin
Dave Kreskowiak27-Sep-05 6:57
mveDave Kreskowiak27-Sep-05 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.