Saturday 1 July 2017

Delegate in c#

What is Delegate in C#.

Delegate is an object which holds the  references to a method  within the delegate object.It is  type safe object and invoking the method asynchronously manner.

Advantage of Delegates

1 Improved the performance of Application
2 Call a method asynchronous.

Type of Delegate 
1. Single Delegate and
2 Multicast  Delegate
3 Generic Delegate

Single Delegate :-A delegate is need to pass single parameter as reference to a method with the delegate object.

using System;
using
 System.Collections.Generic;
using
 System.Text; 
namespace DelegateTest
{
    public delegate void Calc(int x, int y);
    class A    {
        public void add(int x, int y)
        {
            Console.WriteLine("The Sum is " + (x + y));
        } 
        public void sub(int x, int y)
        {
            Console.WriteLine("The Difference is " + (x - y));
            Console.ReadLine();
        }
    }
    class Program    {
        static void Main(string[] args)
        {
            A obj = new A();
            //make an object of class A         

            Calc objsumnew numtest(obj.add);
            objsum(10, 20);
            Calc objsubnew numtest(obj.sub);
            objsub(10, 20);
        }
    }
}


https://msdn.microsoft.com/en-us/library/system.delegate.aspx


Multicast Delegate: - When we need to pass more than one parameter as reference  to a method within delegate object.


Wednesday 28 June 2017

How to find schema changes report in SQL Server ?

How to find schema  changes report in SQL Server ?

Select o.name As [Objcet_Name],
 s.name [Schema_Name],
 o.type_desc [Description],
 o.create_date [Creation_Date],
 o.modify_date [Modified_Date]
 from sys.all_objects o
 Left outer join sys.schemas s
 on o.schema_id=s.schema_id
 where create_date >(GETDATE()-7) or modify_date >(GETDATE()-7)



Or

We can check SSMS  Wizard .
Step 1:- Select Database 
Step 2:-click right mouse button and  Select Report.
Step 3:- Select Standard 
Step 4: finally Select Schema change History . 

How to get logged in User's Security Roles using Java Script in dynamic CRM 365.

 function GetloggedUser () {     var roles = Xrm.Utility.getGlobalContext().userSettings.roles;      if (roles === null) return false;      ...