ado.net return types

  1.  execute non query:
  2. execute reader
  3. execute scalar

execute non query: will return number of records affected through the query

execute reader: will return the dataset

execute scalar: will return the result of aggreagate function.

min/max,avg,count

 

Advertisements
Standard

wanna check sql code

USE [SoftwareTrackingVehicleTest]

go

/****** Object:  StoredProcedure [dbo].[csVCDChassis_s]    Script Date: 6/21/2018 7:36:27 PM ******/
SET ansi_nulls ON

go

SET quoted_identifier ON

go

— =============================================
— Author:    David Kruger
— Create date: 06-19-2018
— Description:  Selects a Chassis from the VCD database View
— =============================================
ALTER PROCEDURE [dbo].[Csvcdchassis_s]
— Add the parameters for the stored procedure here
@VIN NVARCHAR(17)
AS
/******************************************************************/
/*  Select procedure returns:                                     */
/*     a) -999 if an error occurred                               */
/*     b) The number of records selected (0 or 1)                 */
/******************************************************************/
DECLARE @_error INT
DECLARE @_rowcount INT
DECLARE @ret_val INT

SET nocount ON

SELECT @ret_val = 0

BEGIN
— Insert statements for procedure here
SELECT vin,
lastdatemodified,
vpdconfiguration
FROM   vfvehicleconfiguration
WHERE  @VIN = vin;
END

SELECT @_error = @@error,
@_rowcount = @@rowcount

IF ( @_error <> 0 )
BEGIN
SELECT @ret_val = ( 999 )

RAISERROR (‘Select failed in procedure fsChassis_s ‘,16,1)
END
ELSE
SELECT @ret_val = @_rowcount

RETURN @ret_val e

Standard

dapper and stored procedure

  1. sending multiple employe ids to the table
  2. validate them if empid is there then return other wise skip the employess
  3. return multiple records from the stored procedure

multiple values we cant able enter to the procedure so we can able to enter them by adding pipe symbol like below:

 using (SqlCommand cmd = oconn.CreateCommand())
        {
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@keys", SqlDbType.VarChar, -1);
            cmd.Parameters["@keys"].Value = string.Join("|", keys);

            //execute the command
            SqlDataReader rdr = cmd.ExecuteReader();
            rdr.Close();
        }
Standard

kendo ui samples

dropdown button:
@Component({
    selector: 'my-app',
    template: `
        <kendo-dropdownbutton [data]="data" [textField]="'actionName'">
            Edit
        </kendo-dropdownbutton>
    `
})
class AppComponent {
    data: Array<any> = [{
        actionName: 'Undo',
        icon: 'undo',
        click: (dataItem) => {
            console.log(`${dataItem.actionName}ing last action.`);
        }
    }, {
        actionName: 'Redo',
        icon: 'redo',
        disabled: true
    }, {
        actionName: 'Cut',
        icon: 'cut'
    }, {
        actionName: 'Copy',
        icon: 'copy'
    }, {
        actionName: 'Paste',
        icon: 'paste'
    }];
}

 

Standard

solid

s–>single responsibility

o–>open closed principle

l–>liskov substitutional model

i–>interface segrression

d–>dependency injection

s–>single responsibility means

only one responsibility need to give to the class,

if ur dng crud operations in a class dnt write the same class to log the data.

logging store the log data in other class, the class will have only one responsibility.

 

open closed principle:

class is open for extension and closed for modification:

 

 

Standard