Skip to main content

Posts

Showing posts from 2013

How to get collections on viewmodel on postback in MVC

In mvc most of the people will face problem how to bind view model list while post request. If a partial control is binding with a list and want to preserve the user input with view model list, most common issue is id/name is same. If the Id/Name are different only MVC engine can bind it with the model. Please see the below example Build the view/partial view in the following way. By keeping a row counter means all items will have unique names. Suppose this partial view is coming inside a View Called MethodName.ASPX and is included inside the Main Page using html.beginform() [httpGet] { <%html.dropdownlist(model=>model.Test, new {onclick=Test(<%=model.Id%>);}); <.div id="dvPopulatePartialViewWithList"></.div> } Javascript function Test function Test(id) {  $.ajax({         type: "Get",         data: "Id=" + Id,         url: '/MyController/GetPartialViewListById',         succes

Entity framework practices

People who are using entity framework for Dal single dbcontext is going to be a problem in BLL. I use the following structure   I used to get the single dbContext by:- Each single repo class should inherit from base repo class and in base repo class should initialise the dbcontext.   The BaseRepository     public class BaseRepo     {        private readonly bool isNewInstance;        protected OnlineProductLinkEntitiesdbContext;            protected BaseRepository()        {            dbContext = newOnlineProductLinkEntities();            isNewInstance = true;        }          protectedBaseRepository(OnlineProductLinkEntitiesdbContext)        {            isNewInstance = dbContext == null;              if (isNewInstance)                dbContext = newOnlineProductLinkEntities();              this.dbContext = dbContext;        }          protected voidCheckAndTryToOpenConnection()        {            if (dbContext == null)                dbContext = newOnlineProductLinkEntities();    

How to add a stored procedure in Entity Framework

Step1- Open the . edmx file Step2- Right click in . edmx file and select Update Model from Database Step3- Select Add tab, select Stored Procedures and select the procedure you want to add and click finish as shown in below figure a Step4- Build the Entity Project to make sure nothing is broke Step5- Right click on . edmx file and  select Model Browser Step6- Model Browser Popup will appear as  below figure. Click on the Strored Procedures in PricingToolModel . Stroe and click the newly added SP (it will appear here) Step7- The Add Function Import screen will appear Based on the return we can set up. If you are returning a multiple column Click on the Get Column Information First, then click the new Complex Type. After that you can  see the Return of Collection will select the Complex and a complex type is generated by EF If its returning scalar you can select which return type like int , string etc... If its return  entitty  (means table) please sel

Where do you see yourself in next 5 year period?

This question is dedicated to every one who is searching for job. What kind of job you applying, you will meet this question some where in the selection journey. There are lots of techniques available to answer this question. Try to create an answer from  your own experience or from field. Some examples are  First example I am definitely interested in making long term commitment to my next position. What you have told me and from the job description, it is exactly what i am looking for and what i am very grateful to do. In terms of future career plan i am confident that if i do my work with excellence, the opportunities will definitely knock my doors. It is always been that way in my career and i am confident i will surely have the similar opportunity here. I will do the job to best of my ability and keep my eye open for the opportunities in the organisation. I am prepared to learn new things and ready to contribute to the overall success of the organisation in a number of wa

How to Improve Linq Query Performance by using Parallel/ PLinq

How to Improve Linq Query Performance by using Parallel/ PLinq I want to highlight the disadvantage first, because if you know the disadvantage you can make a choice if required in your project or not. Don't use if you have a Single core or dual core CPU's. I found that depending on the complexity of For loop  the CPU performance reaches more than 70-80%  (Not talking about the simple For loop). So if you want to use the parallelism for complex loop make sure you have more than  2 CPU's Parallelization sometimes cause a  PLinq query to run slower than Linq to object equivalent. Basically it said like queries with few data source elements and fast user delegates are reluctant to speed up much. Parallel Linq is the parallel implementation of Linq. Parallel Linq implementation on loops provide better performance compared to sequential  loop. Parallel Linq also works like Linq queries operate on any in-memory IEnumerale ( of T) data source. PLINQ make full use

Tips To Becoming A Leader At Work

Recently   i read an article from Yun   Siang Long At  Careerealism So Thought To Share With My Readers With Some Modification. 1. Take Accountability Take the accountability for   anything   that has your iconic belief in it. That means, as long as you   participate   in the project, you have a hand in the failure of   the   project. Learning accountability means not just the good/ successful  things, but even the   bad/failed   ones. Always find the best way to admit mistakes - it’s all right   to   be wrong, but need to identify and sort out. You cannot become a master, if   you   have not made any mistakes. One of the examples coming to my mind is Dr APJ Abdul Kalams Press Conference after a failed PSLV launch. He took the whole events in his  shoulder  and  briefed  the media with out exposing his colleagues. 2. Always trust In Win-Win Each time a wave falls down they rise again – always think win-win. If we   met   failure   a