🇵🇸 Call for a #CeasefireNOW 🇵🇸

Act Now

HttpApplication EndRequest Event Invoked Many Times In Single Request?

The other day I was putting the last touch of a temporary way to manage the NHibernate session (ISession) in Bunian. So part of the task was to bind a method to the HttpApplication EndRequest event (in the Global.asax.cs file) like the following: public override void Init() { this.EndRequest += WorkContext.NHibernateSessionManager.Instance.HttpRequestEnded; } By doing this, at the end of each page request the NHibernateSessionManager.Instance.HttpRequestEnded() will be called and I can clean the session then. But to my surprise this method was called at least 10 times!! So I thought maybe the Global.Init() method is called many times for some reason and I ended up binding the same method to the EndRequest event many times, so I set a breakpoint at the Global.Init() method and…it’s called one time only. ...

December 14, 2008 · Emad Alashi

Travians be Warned…Rapacious is Rising

I don’t know whether to thank or scold my good friend Omar Qadan for introducing me to Travian, a strategy game played online. It’s amazing how a simple, web-based, HTML-front game can be so rich and vast entertainment-wise. It’s a real strategy game where you build villages, resources, armies, embassies, and conduct trading, diplomacy, wars, and alliances—all through simple images, numbers, and text. On the other hand, I can’t ignore the programming part of the game (being a developer that is). It must be big, fun, and tiring; think of all these rules and the simulation algorithms the game is built upon, the server handling thousands of players, and scripts (yes, lots of hacks! 😄). Even the hacking idea itself is so delicious (programming-wise only 😄), a true heaven for developers. Also, the makers of the game are on the right track of providing developers points through which they can access the game and display information on other sites or applications. For now, it’s only exporting database tables of statistical information about the game status, but still I consider it a cool step toward supplying nice endpoints for developers, maybe Web Services in the future. ...

December 12, 2008 · Emad Alashi

Introduction to NHibernate Session at Jordev Was Good

The feedback was very good, and I was glad that everybody liked it. Jordev is really moving ahead, and I am very excited being part of it 🙂 Below is the slide show (it’s an enhanced version from my previous one): Introduction To NHibernate (SlideShare) Code is the same of the previous one which you can download from here

December 5, 2008 · Emad Alashi

My First Talk at JorDev .net

JorDev .net is a .NET user group founded by enthusiastic Jordanian IT professionals. On Wednesday, November 26, I will be doing my first session in a series about NHibernate. Talk Details Overview: NHibernate is an object-relational mapping (ORM) solution for the Microsoft .NET platform. It provides an easy-to-use framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant amount of relational data persistence-related programming tasks. NHibernate is free open source software distributed under the GNU Lesser General Public License. Target audience: .NET developers, software designers, software engineers, and software architects. Date: Wednesday, November 26, 2008. Location: MIC (Microsoft Innovation Center, Royal Scientific Society Building, 3rd Floor). Time: 6:30 pm to 8:30 pm (Amman, Jordan local time). For more info: Mohamed Saleh: 0788716457 Ayman Farouk: 0795727344 Reminders Live Calendar Facebook event Outlook Calendar Google Calendar

November 21, 2008 · Emad Alashi

Data Access Within Business Objects -Bunian Design-

In a previous post I showed the general architecture of Bunian. I’d like, in this post, to touch on the Data Access part and how it interacts with the Business Objects. In traditional architectures there are 3 known layers: Data Access, Business, and Presentation. DTO’s (Data Transfer Objects) are used to carry the data back and forth between the layers. Look to the following diagram: Bunian contributors seemed to have the same experience developing against such architecture, so we have decided to go with something different; smart Business Objects with more toward OOP. ...

November 9, 2008 · Emad Alashi

Bunian Basic Design

Well, it’s moving on, very slow, but it’s moving! If you have been following this blog, then I think you are familiar with Bunian, the open source project for charity organizations. During the last Bunian team meeting at the beginning of this week, the basic design emerged (still being discussed and subject to changes till the minute of this post); we have decided to skip the dummy DTO objects, and to try Business Objects (BO), where most of the business logic lays, rather than in a separate Business Service. ...

October 23, 2008 · Emad Alashi

NHibernate possible bug in IQuery.List<T>()

recently, we had to clean the database from all the testing data, when an error similar to the following appeared: The value "" is not of type “System.Nullable`1[System.DateTime]” and cannot be used in this generic collection The code I executed was: IQuery query = DbManager.MySession.CreateQuery("select max(dateObject.EndDate) from DateDomain dateObject"); IList<DateTime?> list = query.List<DateTime?>(); When I debugged NHibernate code, I reached to the following AddAll() method in the ArrayHelper class: // NH-specific public static void AddAll(IList to, IList from) { foreach (object obj in from) { to.Add(obj); } } You can find the explanation of the error here. Which brings us to the interesting question: why the implementation of IList Add method doesn’t consider the “nullability” of the T object? and why the parameter is of type IList?! ...

September 21, 2008 · Emad Alashi

Announcing open source project Bunian

What could be better, as an Open Source project, than a charity application! where your code is really worth something valuable; a smile on an innocent orphan face, or new clothes for a needy family in Eid. Announcing new open source project Bunian; the excitement is indescribable! eager to reach with it a stage when it’s really alive, doing something good out there for needy people. I understand it’s going to take so much to drive a successful project, but with the right contributions from the right people like you…I am sure things will just work fine. ...

August 29, 2008 · Emad Alashi

NHibernate Inverse attribute

I had to read documentation, articles, many blog entries and go into discussions with colleagues… all to get the root of this ambiguous attribute of NHibernate, it is trickey! This blog entry is another trial to explain the attribute, but with taking one more detailed step into the explanation. NHibernate is meant to persist objects as well as to manage their relations to each other, lets take a look at the following example of Parent and Child classes: ...

August 22, 2008 · Emad Alashi

Mapping Enumeration of type int in NHibernate

I wanted to map an integer enumeration type in NHibernate, I googled “mapping enumeration in NHibernate” and the best explanation was of Jeremy Miller in his post here. But as it appears (and according to my understanding) that the enumeration type should be mapped to a database column of characters type (varchar, char,…etc). What if the database column was int? well…do exactly like what jeremy did except simply use “NHibernate.Type.PersistentEnumType” instead of “NHibernate.Type.EnumStringType“. ...

August 19, 2008 · Emad Alashi