Naveen's Weblog

Bridge to future

Posts Tagged ‘Difference’

MDF and LDF Files

Posted by codingsense on December 30, 2008

MDF file and LDF file will be created automatically by MSSQL server when we create a new database in MSSQL. The files will be located at Installed Path -> MSSQL.1 -> MSSQL -> Data.
Whenever you create a Database ‘X’ in MSSQL, in the data folder 2 files will be created namely, X.mdf and X_log.ldf.

Difference between MDF and LDF file

MDF file is the Primary database file used by MSSQL in which user data will be present.

For each MDF file there will be a LDF file associated, this is the Transaction log file used by MSSQL to store the user transactions. This file will be used by MSSQL to recover the Primary Database file if it is corrupted.

Is there a need of LDF file?

Some of the users remove the LDF file since it grows very heavily after any transaction in MDF file. But it’s always suggested that to keep the LDF file with MDF file so that in recovery time the user will not repent. For the size problem you can use Shrink Database and Files to decrease the file size.

Happy Learning 🙂

Posted in MSSQL | Tagged: , | Leave a Comment »

Difference between Select and SelectMany in LINQ

Posted by codingsense on September 16, 2008

The difference between select and selectMany can be seen when we are accessing data from multilevel classes.

Download Sample Code – 2.62 Kb

In the below example we shall see what exactly is the difference while accessing the properties.

When we access some data by using select it gives us the data that is grouped under the parent (i.e gives multiple arrays). To access the output we need to loop twice.

////This code shows how to use Select()             
var Query2 = Builders.Select(Build => Build.Locations);

// Notice that two foreach loops are required to iterate through
// the results because the query returns a collection of arrays.            
foreach (List<String> BuildList in Query2)
        foreach (string builds in BuildList)


But using the same sample when we use select many it gives the selected items in one array(i.e it give the output as it is joining all the output from select command)

// Query using SelectMany().            
var query1 = Builders.SelectMany(Build => Build.Locations);

// Only one foreach loop is required to iterate through the
// results because it is a one-dimensional collection.
// Select many joins the output of all the sub collections in to one.            
foreach (string Loc in query1)


Difference select and selectMany

Difference Select and SelectMany

Happy learning 🙂

Posted in LINQ To Objects | Tagged: , , | 11 Comments »