Search Results

Search found 3 results on 1 pages for 'viceberg'.

Page 1/1 | 1 

  • NHibernate listener/event to replace object before insert/update

    - by vIceBerg
    Hi! I have a Company class which have a collection of Address. Here's my Address class:(written top of my head): public class Address { public string Civic; public string Street; public City City; } This is the City class: public class City { public int Id; public string Name; public string SearchableName{ get { //code } } } Address is persisted in his own table and have a reference to the city's ID. City are also persisted in is own table. The City's SearchableName is used to prevent some mistakes in the city the user type. For example, if the city name is "Montréal", the searchable name will be "montreal". If the city name is "St. John", the searchable name will be "stjohn", etc. It's used mainly to to search and to prevent having multiple cities with a typo in it. When I save an address, I want an listener/event to check if the city is already in the database. If so, cancel the insert and replace the user's city with the database one. I would like the same behavior with updates. I tried this: public bool OnPreInsert(PreInsertEvent @event) { City entity = (@event.Entity as City); if (entity != null) { if (entity.Id == 0) { var city = (from c in @event.Session.Linq<City>() where c.SearchableName == entity.SearchableName select c).SingleOrDefault(); if (city != null) { //don't know what to do here return true; } } } return false; } But if there's already a City in the database, I don't know what to do. @event.Entity is readonly, if I set @event.Entity.Id, I get an "null identifier" exception. I tried to trap insert/update on Address and on Company, but the City if the first one to get inserted (it's logic...) Any thoughts? Thanks

    Read the article

  • Identity.Name is disposed in a IIS7 Asp.NET MVC application Thread

    - by vIceBerg
    I have made the smallest demo project to illustrate my problem. You can download the sources Here Visual Studio 2008, .NET 3.5, IIS7, Windows 7 Ultimate 32 bits. The IIS Website is configured ONLY for Windows Authentication in an Integreated pipeline app pool (DefaultAppPool). Here's the problem. I have an Asp.NET MVC 2 application. In an action, I start a thread. The View returns. The thread is doing it's job... but it needs to access Thread.CurrentPrincipal.Identity.Name BANG The worker process of IIS7 stops. I have a window that says: "Visual Studio Just-In-Time Debugger An unhandled exception ('System.Object.DisposedException') occured in w3wp.exe [5524]" I checked with the debugger and the Thread.CurrentPrincipal.Identity is valid, but the Name property is disposed. If I put a long wait in the action before it returns the view, then the Thread can do it's job and the Identity.Name is not disposed. So I think the Name gets disposed when the view is returned. For the sake of the discussion, here's the code that the thread runs (but you can also download the demo project. The link is on top of this post): private void Run() { const int SECTOWAIT = 3; //wait SECTOWAIT seconds long end = DateTime.Now.Ticks + (TimeSpan.TicksPerSecond * SECTOWAIT); while (DateTime.Now.Ticks <= end) continue; //Check the currentprincipal. BANG!!!!!!!!!!!!! var userName = Thread.CurrentPrincipal.Identity.Name; } Here's the code that starts the thread public void Start() { Thread thread = new Thread(new ParameterizedThreadStart(ThreadProc)); thread.SetApartmentState(ApartmentState.MTA); thread.Name = "TestThread"; thread.Start(this); } static void ThreadProc(object o) { try { Builder builder = (Builder)o; builder.Run(); } catch (Exception ex) { throw; } } So... what am i doing wrong? Thanks

    Read the article

  • What do you think of WinDev?

    - by vIceBerg
    I have a job opportunity. They use WinDev. I did some research about it and, although it seams pretty prometting, the website claims that it's used by only 100,000 developpers. Have you worked with this language? What's your thoughts?

    Read the article

1