Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New to MM.NET
Message
From
23/06/2008 19:56:07
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
23/06/2008 17:35:49
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01326209
Message ID:
01326229
Views:
18
Hi Tim,

Welcome to the MM framework.

When you run the Business Layer Generator there are typically three classes created for each entity. An actual entity object, a business object where you place your GetData code, and a rule object. The rule object is where you can add a custom rule with the code you like to test the data and return a message as you wish. If you have a rule object created where there is a ValidateSomeField() method you will see how it is done. Just add a custom rule as you wish and then add a call to it in the CheckRulesHook() along with any others that are called from there.

This is in addition to adding any constraints in your data as you suggested you did to protect your data.

Tim

>Hi,
>
>I am very new to the MM .NET framework and just working through the learning curve.
>
>I am looking for the best method to enforce a unique constraint on a table. I have set up a unique constraint on a varchar field in my table and then used the MM Business Object Wizard to model the table into classes. I can find the validation code for the table, but do not see any code where the framework checks back against the SQL table for uniqueness before attempting the save. When I test the code, I get an exception thrown when the SQL insert statement fails because of the SQL constraint, but I would like to test prior to the statement failing and return something other than a cryptic SQL error to the user.
>
>Inside my validation rules I would like to excute a statement or stored procedure something like the following:
>
>SELECT COUNT(*) AS DupCount FROM MyTable WHERE UniqueColumn = @NewValue
>
>If the count is greater than one, I can send the user a polite "Pick Another Value" message.
>
>Again I am new to MM.NET so I am sure I am just missing something simple, but any help pointing me in the right direction would be appreciated.
>
>Thanks in advance.
>
>Tim Holgerson
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform