Archive April 2019

How to use reserved keyword as variable name in c# ?

Here in c# you can use reserved keyword as variable name, here the sample

string @string = "";

you have to add only @ sign before the reserved keyword, than it will treat as a normal variable. as well as you can also use @ sign with unreserved keywords but its not a good practice, its only a trick.

Insert into SQL database with return inserted id through Insight Database ORM

First of all you should add reference of insight datatabse from nuget package manager. command bellow :

Install-Package Insight.Database -Version 6.2.8

After that just include namespace of insight database .

using Insight.Database;

Query :

these are the paramaeters which we will pass in insert query values

               var parameters = new
                            Name= model.Name,
                            StreetAddress = model.StreetAddress,
                            City = model.City,
                            State = model.State,
                            Zip = model.Zip,
                            PhoneNo = model.PhoneNo,
decimal InsertedId = DB.ExecuteScalarSql<decimal>(@"INSERT INTO [dbo]. 
                                 ) SELECT @@IDENTITY", parameters);

it will return the inserted id in InsertedId variable.

How to get selected checkboxes value using JQuery?

Here 4 checkboxes with same class “chk” and now i want values of checked checkboxes values on a button click

<input type="checkbox" class="chk" id="filterCheckboxSub" value="1" 
<input type="checkbox" class="chk" id="filterCheckboxSub" value="2" 
<input type="checkbox" class="chk" id="filterCheckboxSub" value="3" 
<input type="checkbox" class="chk" id="filterCheckboxSub" value="4" 
<button type="button" id="btnFilter">Filter</button>

Here the jquery code for getting value of selected checkboxes.

 $('#btnFilter').click(function () {

            var chkArray = [];

            $(".chk:checked").each(function () {

            var selected;
            selected = chkArray.join(',');

            if (selected.length &gt; 0) {
                alert("You have selected " + selected);
            } else {
                alert("Please at least check one of the checkbox");