Thursday, 30 March 2017

Constants in AngularJs

Constants can be injected everywhere including configuration calls. So when you call module.config and set up states,colors,months,weeks or other run time settings you can inject constant values.

<html ng-app="app">
<script src="Scripts/angular.min.js"></script>
<body ng-controller ="MyController">
        var app = angular.module('app', []);
        // Storing a single constant value
        app.constant('MOVIE_SAMPLE''The Movie');
        // Now we inject our constant value into a My controller
        app.controller('MyController'function ($scope, MOVIE_SAMPLE){

Constants in angularJs
Constants in AngularJs

Thursday, 23 March 2017

Create and Execute a Simple PLINQ Query

Parallel LINQ (PLINQ) is a parallel implementation of the LINQ pattern. A PLINQ query in many ways resembles a non-parallel LINQ to Objects query.
PLINQ is a query execution engine that accepts any LINQ-to-Objects or LINQ-to-XML query and automatically utilizes multiple processors or cores for execution when they are available
The primary difference is that PLINQ attempts to make full use of all the processors on the system. It does this by partitioning the data source into segments, and then executing the query on each segment on separate worker threads in parallel on multiple processors

Create Parallel LINQ and execute


  PLINQ only works against local collections. This means that if you’re using LINQ providers over remote data, such as LINQ to SQL or ADO.NET Entity Framework, then you’re out of luck for this version.
  Since PLINQ chunks the collection into multiple partitions and executes them in parallel, the results that you would get from a PLINQ query may not be in the same order as the results that you would get from a serially executed LINQ query.

Monday, 13 March 2017

Pass user defined object to ASP.NET Webmethod from jQuery, using JSON

In .html page
        function StoreDataInDatabse() {
            var Employee_Detail = {}
            Employee_Detail.Emp_Name = "Test";
            Employee_Detail.Emp_Age = "24";
            Employee_Detail.Emp_Salary = "1000";
            Employee_Detail.Emp_City = "Ban";

                type: "POST",
                url: "default.aspx/Insert_Data",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
            data: JSON.stringify({ 'Employee_Detail': Employee_Detail }), // Check this call.
                success: function () {

                    alert("Data Has Inserted")

 <input type="button" id="btnSave" value="Save Data" onclick="StoreDataInDatabse()"/>

Default.aspx.cs file

        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static void Insert_Data(Employee_Detail Employee_Detail)


Class file
public class Employee_Detail
        public string Emp_Name { get; set; }
        public string Emp_Age { get; set; }
        public string Emp_Salary { get; set; }
        public string Emp_City { get; set; }

use same properties names in both places(client side and server side)