Search This Blog

Loading...

Sep 9, 2014

How to load XML data in HIVE


Here are the simple steps to load XML data in your Hive .
  1. 1. Login to your Hadoop system and follow the below steps.
  2. 1. CREATE TABLE XMLEmployee(LINE STRING);
  3.  Check table in hive(for confirmation)
  4.     Select * from XMLEmployee-  or
  5.     type  Desc XMLEmployee at hive prompt

Aug 24, 2014

Hadoop Introduction


Hadoop (Apache Hadoop) is a world's best data management system to store and process the largest data( in distributed environment (Cluster), specially for unstructured data or Big Data for e.g. Data from social media such, Govt Data, Weather forecasting etc. Hadoop is good for storing large or Petabytes of data and it is not designed for Real time or low latency queries. Since 1990 Storage capacity has grown exponentially but read speed is not up to the mark, so Hadoop is the solution. In Hadoop 100, 200 drives are working at the same time and can read 1 TB of data in just 2 or less than 2 minutes.  Its a Open system and used by many big clients for e.g. Facebook, Linked In, Google, Yahoo & Indian Govt to process their AADHAR card(A unique Identity for their citizens).

Mar 6, 2014

Delete records from Junction table


Deleting a record from Junction table is very easy, however you can not access junction table in EF directly. For example you have two tables as  Contract and Application , where Contract can have multiple application so many  to many relationship. Here is the solution to delete records from junction table in Entity framework

 // Get the records from both tables, 
//here objContract will return the records from Contract table as well as from the associated tables

  CONTRACT objContract = unitOfWork.Contract.Get(ssc => e.id == contractid).SingleOrDefault();

 // Get specific row which you want to delete from junction table
   if (objContract.JuncApplication.First().APPID == appid)
                {
                    JuncApplication rows = objContract.JuncApplication.Where(e => e.appid == appid).FirstOrDefault();
                    objContract.JuncApplication.Remove(rows);
          //Save context        
unitOfWork.Save();
                }

Feb 15, 2014

How to open Excel File in Browser using MVC

 

I am not demoing file upload approach, however you will not see any file upload control in MVC. You can open any file in MVC either directly from Disk or from database. FilePathResult help us in streaming our file to the browser. There are two ways to open Excel file in MVC

Nov 6, 2013

MultiSelect ListBox in MVC Razor

MultiSelect List box is similar to Listbox(single select) control in Razor view, with the help of multi select property you can make your single select ListBox to a MultiSelect ListBox.

Model Code:-

Declare one Property as

Code Snippet
  1. public List<int>catIds {get;set;}

I am not writing any Model code, I am using service to get the records from table. Just make sure your method should return List/IList/IEnumerable it should be enumerable. something like this

My contract should looks like this(Interface)

Code Snippet
  1. List<MyCategoryTable> MyMethodName();

and in my service method I will implement the MyMethodName, something like this

Code Snippet
  1. public List<MyCategoryTable> MyMethodName()
  2.         {
  3.  
  4.             using (var context = DataContext)
  5.             {
  6.                 var a = context.YourTableName
  7.                     //.Where(mp => mp.Colname == valuename);
  8.                     //Where clause is optional
  9.                 return a.ToList();
  10.             }
  11.         }

above method will return the list of records available in my table, we can put where clause if required, now move to the controller

Controller Code:-

Code Snippet
  1. var category = ServiceProxy.YourService.MyMethodName();
  2.             ViewBag.catList = category.ToList().
  3.                 Select(e => new SelectListItem
  4.                     { Value = Convert.ToString(e.ID),
  5.                     Text = e.Descriptions });

It’s simple, now go to your razor view and

View Code(Razor View)

Code Snippet
  1. @Html.ListBoxFor(model => model.catIds,
  2.         new MultiSelectList(ViewBag.catList,  "Value", "Text"))

That’s It.

Follow by Email