Tuesday, 23 July 2013

Insight Short topics

Note: All this data has been copied from various sources for the purpose of knowledge sharing. Data content  can be either as it is or with little modification.
---------------------------------------------------------------------------------------------------------------------

Order of lifecyle of ASP.NET page in mvc

App initialization
Routing
Instantiate and execute controller
Locate and invoke controller action
Instantiate and render view


=============================================================
Overloading
Overloading is when you have multiple methods in the same scope, with the same name but different signatures.
//Overloading
public class test
{
    public void getStuff(int id)
    {}
    public void getStuff(string name)
    {}
}

Overriding
Overriding is a principle that allows you to change the functionality of a method in a child class.
//Overriding
public class test
{
        public virtual getStuff(int id)
        {
            //Get stuff default location
        }
}

public class test2 : test
{
        public override getStuff(int id)
        {
            //base.getStuff(id);
            //or - Get stuff new location
        }
}

DELETE 
1. DELETE is a DML Command. 
2. DELETE statement is executed using a row lock, each row in the table is locked for deletion. 
3. We can specify filters in where clause 
4. It deletes specified data if where condition exists. 
5. Delete activates a trigger because the operation are logged individually. 
6. Slower than truncate because, it keeps logs. 
7. Rollback is possible. 

TRUNC ATE 
1. TRUNCATE is a DDL command. 
2. TRUNCATE TABLE always locks the table and page but not each row. 
3. Cannot use Where Condition. 
4. It Removes all the data. 
5. TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. 
6. Faster in performance wise, because it doesn't keep any logs. 
7. Rollback is not possible. 

DELETE and TRUNCATE both can be rolled back when used with TRANSACTION. 

If Transaction is done, means COMMITED, then we can not rollback TRUNCATE command, but we can still rollback DELETE command from LOG files, as DELETE write records them in Log file in case it is needed to rollback in future from LOG files.


Unitofwork 

Unitofwork pattern can be applied on all tables having at least one identity column because UOW always check against this identity value to update or to add a new record.


When unitofwork.save() is called it check for change in identity column value. if the value of identity column say  219 does not exists in the table than it will simply insert the new record in table where as if the value of identity column say 219 is already exists than it will update the column against that identity column.

No comments:

Post a Comment