摘要:
Refer to http://stackoverflow.com/questions/785413/difference-between-httpcontext-current-and-controller-context-in-mvc-asp-netThe context provided by the controller (not the static HttpContext.Current) is mockable. If you're interested in unit-testing your code, it's generally far easier to 阅读全文
摘要:
Refer to http://stackoverflow.com/questions/814206/getting-db-connection-through-singleton-classYou won't be able to open multiple SqlDataReaders/Commands with the connection at the same time and will run into thread blocking issues if you are trying to share the same connection object with mult 阅读全文
摘要:
Refer to http://blog.163.com/xhy_cy/blog/static/1049762320112305016599/ private readonly string connectionString; // only can be initializable once private static object syncRoot = new Object();//为了解决多线程,而添加的一个附加变量,以避免死锁 public static SConnection Instance{ get{ if (insta... 阅读全文
摘要:
Refer to http://www.martinwilley.com/net/code/nhibernate/query.html#ToC3E.g.Paging and avoid sql injectionIQuery q = s.CreateQuery("from Job as j where j.ServiceId in (:serviceIds)");q.SetParameterList("serviceIds", ids).SetFirstResult(10).SetMaxResults(10); 阅读全文
摘要:
In short, mapping the properties of multiple entity classes to columns in one table.Refer to http://ayende.com/blog/3937/nhibernate-mapping-component<component/> is an interesting feature of NHibernate, which map more or less directly into the notion of a Value Type in DDD. This is a way to cr 阅读全文
摘要:
1. Download nhibernate (version 3.1.0 GA, latest 3.3.1 doens't have lazy loading related dlls) from http://sourceforge.net/projects/nhibernate/files/NHibernate/2. Create a console application by adding following dlls3. Create a class named namespace TstDBConnection.Entities{ public class Course{ 阅读全文
摘要:
<?xml version="1.0"?><configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/> <section name="log4net" type="log4net.Config.Log4NetConfigurationSecti 阅读全文
摘要:
1. Find the XML schema directory of your VS2010 Express (Beta 2, at this time) installation Tools->Options will point you to the right place. Do not forget to select the Show all settings checkbox at the left bottom of the window:2. Then, go to the folder you extracted the nhibernate binaries int 阅读全文
摘要:
publicclassArrayJsonResult:System.Web.Mvc.JsonResult{ publicoverridevoidExecuteResult(ControllerContext context) { if(context ==null) { thrownewArgumentNullException("context"); } if(JsonRequestBehavior==JsonRequestBehavior.DenyGet&& String.Equals(context.HttpContext.Request.... 阅读全文
摘要:
Refer to http://stackoverflow.com/questions/9610214/pass-complex-json-object-to-an-mvc-3-actionvar testViewModel ={ Name: ko.observable("Joe Bob"), Locations: ko.observableArray([ { ID:1,Name:"Salem, OR"}, { ID:2,Name:"Big Bear Lake, CA"}, { ID:3,Name:"Big Bear Cit 阅读全文