Skip to main content

Posts

Showing posts from July 6, 2014

How To Call An Action In a Controller From A dropdown change event

By Using MVC4 ,JQuery,And Nhibernate sample Code // Script Block $( function () { $( "#resourceSelectList" ). change ( function () { var urlAction = "~/Planner/LoadPlannerWithFilter?value=" ; var value = $( this ). val (); }); }); @* HTML Markup *@ @ Html . DropDownListFor ( x => x . resourceSelectList , Model . resourceSelectList )     And Cotroller Part   public ActionResult PlannerLanding () { WrapperClass wrp = new WrapperClass (); var resourceSelectList = obj . getResourceList () . Select ( x => new SelectListItem { Value = x . Owner , Text = x . Owner }); wrp . resourceSelectList = new SelectL

Sample code for Populating DropDownList Using QueryOver In NH3

    Code For Populating DropDownList     NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();             Assembly myAssenbly = typeof(Contactss).Assembly;  config.AddAssembly(myAssenbly);                 ISessionFactory factory = config.BuildSessionFactory();                 ISession session = factory.OpenSession();                 IList FName =(IList)session.QueryOver<Contactss>().Select(c => c.FirstName, c => c.ContactId ).List<object[]>().Select(x => new {                 fn=(string)x[0],                 Id=(Int32)x[1]                 }).ToList();                 DropDownList1.DataSource = FName;                 DropDownList1.DataTextField = "fn";                 DropDownList1.DataValueField = "Id";                 DropDownList1.DataBind();                 session.Close(); contactss is a Business Model as follows using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebA

NHibernate QueryOver Class And Projection....

Introduction The ICriteria API is NHibernate's implementation of Query Object . NHibernate 3.0 introduces the QueryOver api, which combines the use of Extension Methods and Lambda Expressions (both new in .Net 3.5) to provide a statically typesafe wrapper round the ICriteria API. QueryOver uses Lambda Expressions to provide some extra syntax to remove the 'magic strings' from your ICriteria queries. So, for example: .Add(Expression.Eq("Name", "Smith")) becomes: .Where<Person>(p => p.Name == "Smith") With this kind of syntax there are no 'magic strings', and refactoring tools like 'Find All References', and 'Refactor->Rename' work perfectly. Note: QueryOver is intended to remove the references to 'magic strings' from the ICriteria API while maintaining it's opaqueness. It is not a LINQ provider; NHibernate 3.0 has a built-in

NHibernate Insertion,Updation,Deletion,

Installing NHibernate Download NHibernate ( http://sourceforge.net/projects/nhibernate/). Start a new project. Add reference to the NHibernate.dll by browsing the folders. Copy NHibernate.dll and NHibernate.xml to the Bin folder of the project. (This step is optional if the files are copied automatically) Now NHibernate is installed for the project. Getting Started In our example we have created a web application with the following database design. We will incorporate the basic database operations like Insert, Update and Load. Before that we need to take care of the following things to be added to our project. Add NHibernate Schema definition in Web.config File <Table Name>.hbm.xml File <Table Name>.cs File Insert, Update and Load Operations 1. Adding NHibernate Schema definition in Web.config Web.config is the basic configuration file for a web application. If we are not developing the web application the configuration file name shou