Posts

Showing posts from 2019

Open files in a new browser tab

Today we are going to learn how to display a file in a new browser tab using jquery. I hope it would be helpful. var tab=window.open(URL,'_blank'); if(tab) { win.focus (); } else { alert ('please allow popups for this website'); }

Except in Sql

It's a wonderful functionality in SQL. You may have crossed the situation to select the records those are not available in the second table. However We may use joins to do this. Alternatively we have  direct way to do this by using "Except" keyword. I hope this would be more helpful for you. We must have equal number of expressions in both queries. Example select invoiceid from invoicepayment where invoiceid in(1,2,3) Except select invoiceid from invoice where invoiceid in(1,2) Output 3

Standared Stored procedure structure

Today I'm going to tell you what's the standard way of writing stored procedures. Create proc procedurename Parameters with default value As Begin      Begin try           Begin tran                                         Commit tran       End try       Begin catch              If @@trancount >0              Rollback tran        End catch End

Dictionary in C#

Dictionary is one of the mostly used generic collection in C#. It is a key and value pair collection.Each key inside this collection must be unique. It resides inside System.Collections.Generic library. Example using System; using System.Collections.Generic; public class Program { public static void Main() { CollectionExample(); } public static void CollectionExample() { //Creating new dictionary Dictionary<string,string> userDetails = new Dictionary<string,string>(); //Adding values to dictionary userDetails.Add("Saravanan","SoftwareDeveloper"); userDetails.Add("Aravind","SoftwareDeveloper"); userDetails.Add("Ajith","Programmer Analyst"); userDetails.Add("Prakash","lecturer"); //updating values of dictionary userDetails["Ajith"]="Dotnet Developer"; //Removing values userDetails.Remove("Prakas...

Routing in MVC

*Route is a URL Pattern.  It direct HTTP requests. *Routing is a part of MVC Architecture. *Process of mapping incoming requests to particular MVC controller actions. There are 2 namespaces available to work with proper routing. i) System.Web.Mvc ii) System.Web.Routing Default routes are mentioned in the RouteConfig class. Default routes contain 3 properties i)name- Route name. Route name can't be duplicated. ii)URL-Pattern of URL. Request URL should be  matched with the given URL patterns  otherwise error will be thrown. iii)defaults- Default controller and action name will be given here. Example using System.Web.Mvc; using System.Web.Routing; namespace RouteExample { public class RouteConfig { public static void RegisterRoutes(RouteCollection route) { route.IgnoreRoute("{resource}.axd/{*pathInfo}"); route.MapRoute( name:"Default", url:"{controller}/{action}/{id}", defaults:new { controller="Home",action="Index...

IEnumerable vs IQueryable in C#

Both are used to hold the collection of data and performing data manipulation activities. IEnumerable will retrieve all records from database and doing other data manipulation activities in client. This data can't be modified (insert/delete). IQueryable will   do data manipulation activities in database and return only the final data to client. It will give high performance. Example Assume Employee table has 1000 records. We need to retrieve only "IT" employees. *IEnumerable                  Loads all employee in memory.                  Filters "IT" employees *IQueryable                           Filters "IT" employees from database and return .

History of Asp.net core

ASP(Active Server Page ) was first introduced in 1998 for building server-side technologies. It was initially developed for creating and running dynamic, interactive web applications. It was rendering HTML(Hypertext Markup Language) on the server. It was also known as "Classic ASP" . It evolved to become Asp.net in 2002.  Asp.net includes Asp.net webforms(dynamic form-driven web applications), Asp.net MVC (more advanced web applications based on model-view-controller pattern) and Asp.net web API . Asp.net core was born in 2016. It combined the best of asp.net webforms,MVC and Web API .

Static class in C#

Static Class                            we cannot create an object of that class using the  new  keyword, such that class members can be called  directly using their class name . Created using the  static  keyword. Inside a static class  only static members are allowed , in other words everything inside the static class must be static. We  cannot create an object  of the static class. A Static class cannot be inherited. It allows only a static constructor to be declared. The methods of the static class can be called using the class name without creating the instance.     (e.g) Static class Employee { }

Design principles for Dotnet core

In this section we are going to learn more about the basic design principles for Dotnet core. Developing a clean architecture adhering to the best practices adds several benefits. A few common design principles that should be addressed when designing developing applications in Dotnet core. 1.KISS 2.YAGNI 3.DRY 4.SoC 5.SOLID 6.Caching 7.Data structures 8.Communication 9.Resource management 10.Concurrency 1.KISS(Keep It Simple Stupid)         Writing cleaner code and keeping it simple always helps developers understand and maintain it in the long run. Adding unnecessary complexity in the code makes it less understandable and hard to maintain. KISS principal is used while designing software architecture,using OOP principles, designing the database,user interface and so on. 2.YAGNI(You Aren't Gonna Need It)          YAGNI is one of the core principles of XP(extreme programming). XP is a software methodology. The primary goal is...

Coding Principles in C#

In this section we are going to learn about some of the basic coding Principles that help in writing good quality code that improves the overall performance and scalability of the application. 1. Naming convention   Always use the proper naming convention. *Solution name should provide meaningful information about the project. *Project name should specify the layer or component part of the application. *Solution name should always be different from the project name. Because one solution may contain multiple projects. *Classes should be noun or noun pharses. *Methods should represent the actions. *Pascal casing for Class and method . *Camel casing for parameters and other variables. *In Pascal casing, first letter of every word is capital letter. *  In Camel casing , first letter of every word is small letter . 2.Code Comments  Proper comments assist developers in many ways . It reduces the time to understand the code. So proper Comments should be given. ...

Difference between Overloading and Overriding in C#

Overloading is a concept where we can have same method names with different input signature( Compile Time Polymorphism). In Overriding we have a parent class with virtual functions which are overridden in the child classes( Run time Polymorphism ).

Difference between Abstraction and Encapsulation in C#

Abstraction *Showing only what is necessary *It is done in Design phase. *It can be achieved using Abstract class and interface. Encapsulation *Hiding the unnecessary data. *It's done in Coding phase. *It can be achieved using Access modifiers.

Disadvantages of viewdata and viewbag in Asp.net MVC

*Performance issue- Data inside the viewdata is type of object. So we have to cast the data to correct type. It will affect performance. *We can't get compile time error if we cast to wrong type.

Typescript data types

Typescript is pure object oriented language. The popular JavaScript framework Angular is written in Typescript. Variable declaration is done with the help of the keyword " let " . Boolean let success:boolean=false; Number let age:number=25; let amount:number=12.34; String let name: string=" saravanan"; Concatenation let age:number=25; let name: string="saravanan"; let details: string= name + " age is " + age; Array let amount:number[]=[10,20,30]; Tuple let x:[string, number]; x=["aravind",24]; Enum enum alert {success, failure}; let status:alert=alert.success;

Difference between wcf and Web services

* Wcf services can be hosted in multiple protocols like http,tcp etc. Whereas web services can be hosted only on http protocol. *Two different wcf services can be called in a transaction whereas we can't call two different web services in one transaction .

Difference between stored procedure and function

* CRUD operation can't be done using Function whereas it's possible using Stored procedure. *Function can return only one value whereas Stored procedure can return zero or more values. *Function can have only input parameters whereas Stored procedure can have both input and output parameters. *Stored procedure can't be called from Function whereas Function can be called from Stored procedure.

Characteristics of Microservices

* Small in size * Messaging enabled * Bounded by contexts * Autonomously developed * Independently deployable * Decentralized * Built and released with automated processes.

Advantages of Microservice architecture

* Micro sevices is the process of breaking larger application into loosely coupled modules, which communicates with each other through small APIs. * We can identify the bottlenecks in services and fix them without massive rewrites. * Developers can test services easily because every services would be smaller. *Applications are smaller ,so it will be  deployed quickly. * Services are limited, so it's obvious to monitor each of these instances. *Each services are independent. So if one service fails others will work without any interruptions . * Easy to understand since they serve a small piece of functionality. *Micro services are pure agile and works hand in hand with DevOps . *Smaller code bases make maintenance simpler and faster.

Disadvantages of Monolithic architecture

*The code base grows with in it when application grows. *If any single application or component fails ,then the entire application goes down. *If a single change to the system would require the whole application to be redeployed. *Developers can't work independently to develop or deploy their own modules.

Asp.net MVC

MVC is an architectural pattern. It's divided in to three broad sections. The main benefit of MVC is Separation of Concern (SoC). Through this SOC we can reuse the code to a great extent.We can manage the code efficiently by this architecture. 1.Controller(C) 2.Model(M) 3.View(V) 1.Controller(C)   Controller will handle the user's requests and send the response. Controller is responsible to load the appropriate "Model" and "View" via Action methods. Controllers are the central part of the MVC architecture. Action methods- Action methods are simply a public method inside controller which accepts user's request and returns some response. (e.g) public class TestController: Controller { public string GetString() { return "Everything will be alright"; } } 2.Model(M)   Model provides data to the "View". Model represents "Business data". Data from controller to view will be passed in the form of "Model". ...

Asp.net Web forms

Introduction Asp.net web forms has been serving successful web application development  for last 12 years. It is due to RAD(Rapid Application Development) and visual programming approach. The name of Microsoft's IDE(Integrated Development Environment) is "Visual Studio". In Asp.net web forms default response is always HTML .If we want to return something other than HTML We have to create HTTP handlers, override content type,do Response.End etc. The visual RAD architecture of Microsoft has two components. They are 1.UI- ASPX 2.Code Behind-ASPX.cs Problems in web forms Performance It's the biggest problem in web forms. The main reason for this is, conversion from sever controls to HTML controls. This conversion happens for every request. It will take more time to convert If we have data controls such as Gridview,Treeview etc. The other cause of performance is ViewState. It does a good job that saves states between postbacks. However ViewState increases the pa...

Know Something more about Tenses in English

Already we have seen about tenses in  our previous articles.However here i am going to give  some shortcuts in this articles. 1.Simple Present Tense       Usages: Habit,Truth or fact.   Keywords: Every morning,weekly,seldom,always,often,sometimes,monthly,annually etc.   Example:   He studies every morning.   Do you work at night?   The sun rises in the morning. 2.Present Continuous Tense      Usages: A continuous action or event that is still going on.    Keywords: Now,at this moment    Example:    I am studying now.    She is cooking at the moment.    Are you reading? 3.Simple Past Tense     Usages: An action that takes place in the past,Habitual past action   Keywords :Last week,last month ,just now,two hours ago,in 2018,yesterday .   Example:   He ate lunch just now.   Prakash played football when he was young. ...

Memory types in Dotnet

Dotnet has 2 memory types. They are 1.Stack 2. Heap 1.Stack These are Value types which contain actual data. (e.g) Int, float, double,Boolean etc. 2.Heap These are reference types which contain pointers. These pointers point actual data. (e.g) String, object etc. The process of moving data from value type to reference type is called BOXING .The vice versa is called UNBOXING .

Common Language Runtime(CLR) in Dotnet

CLR(Common Language Runtime) is the Heart of Dotnet framework . It does 4 primary tasks. They are 1.Garbage collection 2.CAS(Code Access Security) 3.CV(Code Verification) 4.IL to Native translation 1.Garbage collection Garbage collector is a feature of CLR which cleans unused managed objects and reclaims memory. It doesn't clean unmanaged objects. It's a background thread which runs continuously for a specific intervals. 2.Code Access Security CAS is the part of Dotnet security model which determines what kind of rights does a Dotnet code have. 3.IL to Native translation This translation is done by the JIT(Just In Time) compiler. IL(Intermediate Language) is a partially compiled code).

String functions in C#

Today we are going to learn about string functionalities in C#. It is very essential to know the basic string functionalities.So that we can easily work with strings.Here I have listed few functionalities.I hope it would be more helpful. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace StringFunctionalities {     public class Program     {         public static void Main(string[] args)         {             //Display string             string myString="Nothing will be interesting if you are not interested";             Console.WriteLine(myString);     ...

Indian States and their capitals

1. Andrapradesh -Amaravathi Important cities:Anantapur,Nellore,Machilipatnam 2.Arunachal pradesh -Itanagar Important cities:Tawang,along,Anini,Tezu 3.Assam -Dispur Important cities:Guwahati,Tezpur,Jorhar,Silchar 4.Bihar -Patna Important cities:Haha,Siwan,Chhapra 5.Chhattisgarh -Raipur Important cities:Ambikapur,Bilaspur,durg 6.Goa -Panaji Important cities:Margao 7.Gujarat -Gandhi nagar Important cities:Ahmedabad,Surat, Rajkot,Bhuj 8.Haryana -Chandigarh Important cities:Kurukshetra,Hisar,Karnal,Jhajjar 9.Himachal Pradesh -Shimla Important cities: Dharmsala,Kullu,Solan 10.Jammu and Kashmir -Srinagar Important cities:Baramula,Anantnag,Lah,Kargil 11.Jharkhand -Ranchi Important cities:Bokaro,Dhanbad,Jamshedpur 12.Karnataka -Bengaluru Important cities:Mysuru,Kolar,Bijapur,Bidar 13.Kerala -Thiruvananthapuram Important cities:Kollam,Kottam,Palakkad, Kozhikode 14.Madya Pradesh -Bhopal Important cities:Uijain,Indore,Balaghat,Panna 15.Maharastra -Mumbai Important...

Difference between method and function in c#

*Methods return nothing *Functions return something

Difference between IApplicationBuilder.Use() and IApplicationBuilder.Run() in Dotnet core?

IApplicationBuilder.Use () *It is used under configure method of Startup class. *It is used to add middleware delegate to the application request pipeline. *It will call the next middleware in the pipeline. IApplicationBuilder.Run() *It is used under configure method of Startup class. *It is used to add middleware delegate to the application request pipeline. *It will not call the next middleware in the pipeline. System will stop adding middleware after this method.

Normalization in sql

Normalization is a database design technique. It reduces redundancy and dependency of data.It divides larger tables into smaller tables and links them using relationships. 4 types of normalizations are used. 1. First Normal Form(1NF ) *Each table cell should have a single value. *Each record should be unique. 2.Second Normal Form(2NF) *It should be 1NF *Primary key column 3.Third Normal Form (3NF) *It should be 2NF *No transitive dependency 4.Boyce code Normal Form *All the colums in the table should be dependent on the super key.

Difference between Sub query and Derived table in Sql

Derived Table * It's used in from clause. *It can have one or more colums *It must be enclosed with parenthesis. *It should have a name (e.g) Select * from (Select employee_name,sum(salary) as wage  from employee group by employee_name)a Sub query *It's used in where clause *It can have only one column *It must be enclosed with parenthesis. (e.g) Select * from employee where employee_id in (select max(employee_salary) from employee)

Asp.net Core

Asp.Net Core ASP.NET Core is a web framework created by Microsoft for building web applications, APIs, and microservices. It uses common patterns like MVC (Model-View-Controller), dependency injection, and a request pipeline comprised of middleware. It's open-source.ASP.NET Core runs on top of Microsoft's .NET runtime. Advantages Dotnet core is very fast.ASP.NET Core is also optimized for multithreading and asynchronous tasks. Asp.net core has a built in package manager(nuget) to download the necessary packages. Asp.net core is more secure. Components of Dot net Core  Program.cs  and Startup.cs            These files set up the web server and asp.net core pipeline.The startup.cs is the class where we              add middlewares,registering our services with container.       2.Models,Views and Controllers            These are the directorie...

Some Basic SQL Tips

1.Boolean data type         bit 2.Get the current datetime       select getdate() 3.Find the character location in the given string       select charindex('.','lkji.') 4.Replace the specific string or character with some other in the given string       select replace('lkji.','.','-0') 5.Calculate the length of the given string       select len('hello') 6.Find the current time in hours       select datepart(hour,getdate()) 7.Find the day number of current date in total days of year      select datepart(dayofyear,getdate()) 8.Find the week day number of current date       select datepart(dw,getdate())   9.Remove the white spaces of left and right side of the given string       select ltrim(rtrim('   lkjkj   ')) 10.Get the date before...

Differences between Abstract class and Static class in C#

Today we are going to see the differences between abstract class and static class in c#. It is very important thing in c#. We have there are 4 types of classes in c# such as abstract,static,partial and sealed. Sl.No Abstract Class Static Class 1. Object can’t be created Object can’t be created 2. Created using Abstract keyword Created using Static Keyword 3. It should be Inherited to access data Use class name with dot operator to access data 4. Can be inherited Can’t be inherited

Using comma separated values in SQL

we can use comma separated values as input in sql. For this we should use some xml queries. Use the below query. declare @emp_id varchar(6000) set @emp_id ='clkl23,kjlj90,89kjm,88474ur,' select distinct employeename from employee where emp_id in( SELECT t.c.value('.', 'VARCHAR(6000)')            FROM (                  SELECT x = CAST('<t>' +                   REPLACE(@emp_id, ',', '</t><t>') + '</t>' AS XML)                 ) a      CROSS APPLY x.nodes('/t') t(c) )

Benefits of Asp.net Core

Asp.net Core is the free,open source and cloud optimized web framework which will run on any operating system such as windows,linux and mac.It is a new technology developed by Microsoft. now we'll see vividly about Asp.net core. Asp.net core applications will run on windows,linux and mac. So we don't need to build separate application for different platforms using different frameworks. Asp.net web applications can be hosted in multiple platforms with any web server such as IIS,apache and so on.It is independent. Asp.net core application runs on Dotnet core framework. Asp.net MVC and Web API have been merged into one. Inbuilt dependency injection. Json based project structure  Compilation is done with new Roslyn real time compiler.

Triggers in SQL

Triggers are special type of procedures which fire implicitly or automatically.There are 2 types Triggers available in sql.They are 1.DDL Triggers 2.DML Triggers 1.DDL Triggers                              This trigger will fire while doing DDL operations. (e.g)  create trigger Employee on database for create_table,alter_table,drop_table as print'you can not create ,drop and alter table in this database' rollback; 2.DML Triggers                              This trigger will fire while doing DML operations. (e.g) create trigger deep on tblemp for insert,update,delete as print'you can not insert,update and delete this table ' rollback;

Entity Framework Core

Introduction Entity framework core is the new version of Entity framework .It is an Object Relational Mapping framework .In olden days we were using ADO.Net to connect database from backend. We can use it even now also. However Entity framework has some advance features to connect ,access and store data from various databases.Entity framework is the enhancement of  ado.net . Types of Entity Framework Core                  Entity framework core has 2 approaches .They are 1.Code first 2.Database first 1.Code first     In this approach database and tables  are created EF Core. 2.Database first     In this approach domain and contexts are created EF Core from the existing database. Parts of Entity Framework Core DbContext Class              The dbcontext ...

Habits for a good life

Live your life as if there’s no tomorrow. Think as if this is your last day in the world because if you will do your best in everything you will have no regrets. Be adventurous. Conquer your fears. Don’t let your emotion control you. Be unique. Don’t be afraid to be different because sometimes being different is good. Be a risk-taker to have a good career. If you wouldn’t try and explore new things you wouldn’t be able to learn in life. Life will teach you how to live. Your failures, mistakes and success will either make or break you. Study hard and work hard. Always smile it gives people happiness as well to you. If you smile other people will also smile. Be a good person. Help those people who are in need. Believe in what you truly believe Love yourself, your family and your friends. Share your love to everybody because every human being in this world deserve to be loved. Treasure your loved ones. Find friends who will make you push to work harder, who encourage and inspi...

About the Saree of Mother

Mummy your saree is like the sky Mummy your saree is like the sky Mummy your saree is like the sky Make a cradle to sleep ,make a swing to play to catch fish in the river, to dry the fathers head Make a cradle to sleep ,make a swing to play to catch fish in the river, to dry the fathers head want to cuddle it if see cover me if i die by it want to cuddle it if see cover me if i die by it Mummy your saree is like the sky Mummy your saree is like the sky if act inside the tank it is beautiful coral garland, your saree will cover if fingers injure the saree which you wear is giving a tear fragrance if your saree bring water it will be sweetest as sugar it will be spreaded as a peacock feather inside my soul it will give light if it is fired your saree is flower garden. Mummy your saree is like the sky Mummy your saree is like the sky For sisters training,for pasture the goats to stop the sunlight by covering the upstair Mummy...

One man one man owner

One man one man is owner,all the rest is workers. one who think about the fate is loser. one who win the fate is winner. Why do we need weapon to win the earth? Why do we need axe to pluck the flower? Gold or thing ,why should we need battle? If we leave our desire,world would be ours. Human has wish over soil and soil has wish over human. In the last soil wins but mind doesn't accept this fact. If you have some money on your hand, you would be the owner of it. If you have money till your neck, it would be the owner of you. Understand the meaning of life , drink the life. Sky is yours and earth is yours. Why do we have fight with boundaries? Nature tells to live. Sadness in life is artificial. Birds ask me how are you? When  they see me. Buds say pearl pearl when they bloom. Sweetness won't go,senectitude won't come to me .

Principles of REST API

Some of the most important concerns that a RESTful architecture affects include performance, scalability, simplicity, interoperability, communication visibility, component portability and reliability. Principles of REST 1.Client server 2.Layered system 3.Stateless 4.Uniform Interface 5.Cache 6.Code on demand

Why do REST APIs so fast?

REST APIs are stateless in nature. It means server doesn't store any state about the client session on the server side. Client session is stored on the client.

Design Patterns in C#

Design patterns are solutions for software design problems we find repeatedly in real world application development.There are 23 design patterns which are grouped under 3 main categories. Creational design pattern Factory method Abstract factory Builder Prototype Singleton    2.Structural design pattern Adapter Bridge Composite Decorator Facade Flyweight Proxy    3.Behavioral design pattern Chain of responsibility Command Interpreter Interator Mediator Memento Observer State Strategy Visitor Template method

Class with Constructors in C#

Todays session we are gonna learn how to create a class with more then one constructors and what are the components of a class . Constructors are used to initialize the data members present in a class. using System; namespace Test {   class Animal   { private string _animalType; // data members or fields private int _animalCount;    // data members or fields public Animal()           // Default constructor { _animalType=""; _animalCount=0; } public Animal(string animalType,int animalCount)  // parameterized constructor { _animalType=animalType; _animalCount=animalCount;     } public string animalType              // Property { get{ return _animalType;}        // Accessor set{ _animalType=value;}          // Mutator } public int animalCount             ...

Data structures

Data structures                         A data structure is the way of storing and unifying data . Any type of object that stores data is called a data structure. There are 2 types of data structure. They are I.Primitive II. Non primitive I.Primitive              Primitive types are value types such as 1. Signed integer(sbyte,short,int,long) 2.Unsigned integer(byte,ushort,uint,ulong) 3.Unicode characters(char) 4.IEEE floating point(float,double) 5. High precision decimal (decimal) 6.Boolean(bool) 7.Nullable 8. String 9.Object II.Non primitive               Non primitive types are user defined types . Further it is divided in to 2 types. They are i)Linear ii)Non linear i)Linear         In linear da...