Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4265694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:39:32+00:00 2026-05-21T06:39:32+00:00

I am developing a data-driven web application using ASP.Net MVC 3. I will be

  • 0

I am developing a data-driven web application using ASP.Net MVC 3. I will be using NHibernate for data access, but my question is language agnostic (applies to all languages which have the exception concept).

I have come to the conclusion that I better enforce my data integrity rules both in the actual database and in the repository implementation to retrieve said data, for security and edge cases where the offered integrity mechanisms is not flexible enough.

Question

I am thinking I should probably encapsulate said validation inside my IRepository implementations. Using for example a custom MVC validation attribute to query the database for validation sits unnatural in my mind; such processing seems better left for somewhere else.

If I perform my validation in the IRepository implementations, how should I propagate it to the calling context?

I see a few options:

  • Subclassing Exception with something like ValidationException (or if it already exists). Provide the USER FRIENDLY message as the Message property.

The above is easy to implement, but it assumes that the calling context wants to display text to the user. It also makes it hard for the calling context to provide localization (something I believe has no place in an exception – I hate attempting to translate before googling!).

  • Same as above, but instead of a text message provide ValidationException<ValidationEnum>, where ValidationEnum is an Enum which describes the error for the subject model.

This allows the calling context full freedom in interpreting the error. I am leaning towards this method, even though it contaminates the code with a huge amount of enum values.

Are there any other options than these that are more beautiful?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:39:33+00:00Added an answer on May 21, 2026 at 6:39 am

    Depending on the architecture, implementing IDataErrorInfo on your domain types might be an option; this allows you to indicate failure at both the object and object+member level, and IIRC this is now also handled automatically by MVC (a number of other frameworks such as winforms etc have supported this for ages).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on developing my first Data Driven Domain using Dependency Injection in ASP.net.
I am developing large data collecting ASP.Net/Windows service application-pair that uses Microsoft SQL Server
We're developing a data heavy modular web application stack with java but have little
I am developing the framework for what will be a large data-driven Silverlight application
I'm developing a data-driven application using Core Data. I display the tables from the
I am developing a web application which reads data from excel file (xlsx). I
I'm developing an ASP.NET form for data-entry. Users have to select a client from
I'm developing a simple servlet/JSP, data-driven web site on Google App Engine. I've started
The web application I'm currently developing supports CSV export from (using SELECT INTO OUTFILE)
I'm in the process of developing an ASP.NET MVC project, and after several weeks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.