Difference between LINQ and Stored Procedures?
There are couple of advantage of LINQ over stored procedures.
1.Debugging - It is really very hard to debug the Stored procedure but as LINQ is part of .NET, you can use visual studio's debugger to debug the queries
2.Deployment - With stored procedures, we need to provide an additional script for stored procedures but with LINQ everything gets complied into single DLL hence deployment becomes easy.
3.Type Safety - LINQ is type safe, so queries errors are type checked at compile time. It is really good to encounter an error when compiling rather than runtime exception!
Disadvantages of LINQ over Stored Procedures
- PreCompiled: Stored Procedures are precompiled, and LINQ queries need to compile before execution. So stored procedures are fast in performance.
Advantages of LINQ over Stored Procedures
Disadvantages of LINQ over stored procedures:
- LINQ needs to process the complete query, which might have a performance impact in case of complex queries against stored procedures which only need serialize sproc-name and argument data over the network.
- LINQ is generic, whereas stored procedures etc can take full advantage of the complete database features.
- If there has been a change, the assembly needs to be recompiled and redeployed whereas stored procedures are much simpler to update.
- It’s much easier to restrict access to tables in database using stored procedures and ACL’s than through LINQ.
Are LINQ to SQL entities Business Entities or Data Transfer Objects? |
How do I get default values from the database when inserting new entit |
What is Language Integrated Query (LINQ)?
LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations. It extends VB, C# with their language syntax for queries. It also provides class libraries which allow a developer to take advantages of these features.
Difference between LINQ and Stored Procedures.
Difference between LINQ and Stored Procedures:
- Stored procedures normally are faster as they have a predictable execution plan. Therefore, if a stored procedure is being executed for the second time, the database gets the cached execution plan to execute the stored procedure.
- LINQ supports type safety against stored procedures.
- LINQ supports abstraction which allows framework to add additional improvements like multi threading. It’s much simpler and easier to add this support through LINQ instead of stored procedures.
- LINQ allows for debugging using .NET debugger, which is not possible in case of stored procedures.
- LINQ supports multiple databases against stored procedures which need to be re-written for different databases.
- Deploying LINQ based solution is much simpler than a set of stored procedures
Pros and cons of LINQ (Language-Integrated Query)
Pros of LINQ:
- Supports type safety
- Supports abstraction and hence allows developers to extend features such as multi threading.
- Easier to deploy
- Simpler and easier to learn
- Allows for debugging through .NET debugger.
- Support for multiple databases
Cons of LINQ:
- LINQ needs to process the complete query, which might have a performance impact in case of complex queries
- LINQ is generic, whereas stored procedures etc can take full advantage of database features.
- If there has been a change, the assembly needs to be recompiled and redeployed.
Can I use LINQ with databases other than SQL Server? Explain how
LINQ supports Objects, XML, SQL, Datasets and entities. One can use LINQ with other databases through LINQ to Objects or LINQ to Datasets, where the objects and datasets then take care of database specific operations and LINQ only needs to deal with those objects, not the database operations directly.
What is assembly manifest? What is the information it provides? - June 03, 2009 at 11:00 AM by Shuchi Gauri
What is assembly manifest? What is the information it provides?
Assembly Manifest is a file that contains data that describes how the elements present inside an assembly are connected to each other. The assembly manifest contains assembly metadata to define the scope of the assembly and resolve references to resources and classes.
Information provided by Assembly Manifest:
a. Assembly Name
b. Version Number
c. Culture
d. Strong name
e. List of files inside the assembly
f. Reference information
b. Version Number
c. Culture
d. Strong name
e. List of files inside the assembly
f. Reference information
What are Satellite assemblies and how to generate Satellite assemblies?
To support the feature of multiple languages, we need to create different modules that are customized on the basis of localization. These assemblies created on the basis of different modules are knows as satellite assemblies.
Steps to generate satellite assemblies:
a. Set the paths for resgen and al.exe:
b. Create a .resources file.
c. Create the satellite assembly.
d. The assembly should have the naming convention for .NET to be able to search for it.
e. Specify the settings for culture.
f. Put the satellite assembly in the appropriate folder.
g. Once the satellite assembly is created, physically copy it to the appropriate directory.
h. Repeat the process for each language in which you are creating an assembly.
b. Create a .resources file.
c. Create the satellite assembly.
d. The assembly should have the naming convention for .NET to be able to search for it.
e. Specify the settings for culture.
f. Put the satellite assembly in the appropriate folder.
g. Once the satellite assembly is created, physically copy it to the appropriate directory.
h. Repeat the process for each language in which you are creating an assembly.
What is Satellite Assembly?
Satellite Assemblies are language-specific assemblies and are used for language-specific resources for an application. Each assembly of this kind has a separate language specific ID and is installed in a language-specific subdirectory for each language.
Define AL.EXE and RESGEN.EXE
Al.exe: It embeds the resources into a satellite assembly. It takes the resources in .resources binary format.
resgen.exe:The input for Al.exe is generally plain text or XML-based resource files i.e. in .resx format. resgen.exe is used to convert such resources to the .resource in binary format which makes then compatible with al.exe.
resgen.exe:The input for Al.exe is generally plain text or XML-based resource files i.e. in .resx format. resgen.exe is used to convert such resources to the .resource in binary format which makes then compatible with al.exe.
Explain the concepts and capabilities of Assembly in .NET
An assembly is a collection of files (dll’s, exe’s), group of resources that help in creating a logical unit of functionality. It forms the basic building block for deployment, reusability and security issues.
- It provides a CLR environment.
- It helps in maintaining security as it grants grant or denial of permissions.
- When an application starts only assemblies the application initially calls must be present.
- Assemblies can be either static or dynamic.
- Assemblies help in resolving versioning issues.
What is Globalization and Localization in ASP.NET?
Define Resource Files and Satellite Assemblie
Resource Files:A resource file contains non-executable data that are used by the application and deployed along with it. Bitmaps, Icons etc are the examples of resource files. In ASP.NET, resource files are used to make application to support multiple cultures. You can create resource files each of them correspond to specific locale or culture of the application. You can use resgen utility to compile resource file into an assembly. You can create a satellite assembly from a compiled resource file using the AL utility provided with Microsoft .NET SDK.
Advantages of resource files are as follows.It supports Globalization features in ASP.NET.
You can have culture based information separate from the content and logic of the application.
You can change resource content without effecting application's code.
You can have culture based information separate from the content and logic of the application.
You can change resource content without effecting application's code.
Satellite Assemblies Satellite Assemblies are the special kinds of assemblies that exist as DLL and contain culture-specific resources in a binary format. They store compiled localized application resources. They can be created using the AL utility and can be deployed even after deployment of the application.
Satellite Assemblies encapsulate resources into binary format and thus make resources lighter and consume lesser space on the disk.
Note: Resource-only assemblies can contain any resource, such as images and text. Satellite assemblies contain only culture-specific resources.
Satellite Assemblies encapsulate resources into binary format and thus make resources lighter and consume lesser space on the disk.
Note: Resource-only assemblies can contain any resource, such as images and text. Satellite assemblies contain only culture-specific resources.
Difference between candidate key and primary key
Candidate Key– A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key.
Primary Key– A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key.
One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and future normalization. For a Candidate Key to qualify as a Primary Key, it should be Non-NULL and unique in any domain. I have observed quite often that Primary Keys are seldom changed. I would like to have your feedback on not changing a Primary Key.