How do I Handle Business Logic Exceptions?

Please install Silverlight or click download to watch video locally.

This video shows you how to add validation to the data model. You will be able to see how that validation logic is reflected in the UI.

Presented by Scott Hanselman

Duration: 5 minutes, 32 seconds

Date: 08 May 2008

Watch    Video   |   Download    Video

Video downloads: WMV  |  Zune  |  iPod  |  PSP  |  MPEG-4  |  3GP

Audio downloads: AAC  |  WMA  |  MPEG-4  |  MPEG-3  |  MPEG-2

Comments : 12

Leave a Comment

CODEWIRE.NET : On May 31, 2008 4:59 PM said:

How du I access Session in the partiel method like  OnValidate? I want to set a field to a session-variable on every insert.

if (action == System.Data.Linq.ChangeAction.Insert)

{

  Id = Guid.NewGuid();

  AccountId = Session("AccontId"); // Current account

}

shanselman : On June 09, 2008 2:25 PM said:

You would need to use HttpContext.Current.Session, but I think you'd be tying your model objects to the Session which could limit your design's usefulness in other projects.

shanselman : On June 09, 2008 2:25 PM said:

You'd need to use HttpContext.Current.Session.

Dom Márcio : On July 07, 2008 10:39 PM said:

Hi Scott. How can I implement business logic in the Delete-Insert-Update/Object partial method in the DataContext partial class? Thanks in advance.

EdSF : On August 25, 2008 7:52 PM said:

Thanks for all your work on these videos!

jtwebman : On September 29, 2008 6:40 PM said:

Scott first off thank you very much for the videos! I am starting to understand the power of Dynamic data.

One question that throws red alerts in my mind is using exceptions for validation. Is there way to tie in a more simple validation like in Rocky Lhotka CSLA framework of having a collection of validation errors instead of throwing a expensive (time and cpu) exception?

Thanks!

dev01 : On October 15, 2008 4:45 PM said:

I created a partial class Product and implemented OnProductNameChanging just like Scott in the video. It fires 3 times with new value, old value and then again new value of the product? Therefore throwing ValidationException the second  time it fires with the value Chai instaed of ACME.

mgrassman : On October 17, 2008 3:01 AM said:

I got the same as above any solution/how to check which value we are using.

Thanks for the great tutorials.

djibril_chimere_DIAW : On October 31, 2008 11:58 AM said:

Thanks! Jërëjëf!

pg.net : On December 09, 2008 2:10 AM said:

When I try to validate some value and throw exception let's say in OnContentIDChanging(int? value) method I will recieve JavaScript error (exception) instead of "validation summary" error. I'm experiencing this problem only with nullable types. Any idea where is the problem or how to solve this?

Thanks in advance!

rami_nassar : On February 10, 2009 5:53 AM said:

well done

kannank7 : On September 24, 2009 12:53 AM said:

thanks for the validation presentation, but if I want to apply my validation in just one page for e.g. let us say Insert and not in Update. where do i have to write it ?

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities