Some doubts about how this query is handled in C#? -


I am absolute new in C # (I came from Java) Doubt the following code.

So when a manager class that can work on a DB table, I have something like:

  public class UserManager: ManagerDB {// Define the a t1 field to select the database table: public const string _sqlElencoUtenti = ", t1.my_login, t1.nome, t1.cognome, t1.email, t1.date_added, t1.date_last_login, select t1.is_enabled, t1 t1.user_id Please customer_id, t1.uidad "; // MyUser Object Public List & lt; Models.MyUser & gt; Return a list of filtered MyUser objects based on the values ​​entered in getList (totalRecords rounded out, Models.MyUser filters, integer pageSize = -1, int pageIndex = -1, string type = from "MY_LOGIN", string SortOrder = "ASC") {List & lt; Models.MyUser & gt; result; Results = New list & lt; Model My user & gt; (); // Select the interesting areas from the UTENTE DB table: _strSQL = _sqlElencoUtenti + "from U1NTE to T1"; System.data Common DB commodity order; Order = _connection.CreateCommand (); String strWHERE = ""; // If so, where is the connection start (filter! Is = null) {// If a filter object exists query used to filter // If Mayusr filter Object Name field blank not and is not empty: if (! String IsNullOrEmpty (filter.nome)) {// Create a new Strofeyr who bent my representation + = "and Nome as @body"; AddParameter (command, "bomb", "%" + filter name; "%"); } ................................ ................. ............... ................................}}}  

So I have some doubts about what is done at the end of the previous code

It seems that if the area Nom (name) MyUser filter object anonymous strWHERE string (where queries are condiction representation) is to valorize and not empty.

Two things that I do not understand is that what is the exact roole of @one inside the line

  strwhare = "NOME";  

And what this second line actually does:

  addParameter (command, "@ GNOME", "%" + filter.nome + "% ");  

TNX

Andrea

@ Numerology works as a placeholder, it tells the SQL that you want to add a parameter to the query. The AddParameter function, then tells the SQL command that the resolution of which resolution should be resolved.

Hope it helps.

Happy C # 'ing !!


Comments