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 7857023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:53:59+00:00 2026-06-02T20:53:59+00:00

The title is somewhat self explanatory. I have an entity that has another key

  • 0

The title is somewhat self explanatory. I have an entity that has another key already defined (that must remain that way) and I need to validate that a certain field is unique.

I am hoping to use a Validator applied in the metadata. But I can’t use DomainService there since the code must run on both Server and Client. So I have no idea how I could access my entity set to see if the field’s value is unique….

Ideas?

Thanks!

  • 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-06-02T20:54:01+00:00Added an answer on June 2, 2026 at 8:54 pm

    The way to do this is to create a file with the extension .shared.cs on the Server side. Put the validator in that:

    public class CustomValidation
    {
         public static ValidationResult ValidateUnique(object o, ValidationContext c)
         {
             #if SILVERLIGHT
                 //Do actual validation client-side:
                 MyObject mo = c.ObjectInstance as mo; //Object we are checking is type MyObject
                 MyDS ctx = new MyDS; //Domain Service
                 System.ServiceModel.DomainServices.Client.InvokeOperation<bool> 
                        isUnique = //some invoke operation in Domain Service;
    
                 isUnique .Completed += (s, e) =>
                 {
                     if (!isUnique .HasError && !isUnique.Value)
                     {
                          //return error;
                          mo.ValidationErrors.Add(error);
                     }
                 };
             #endif
             //Server-side always returns success:
             return ValidationResult.Success;
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Title is quite self explanatory, but I have some animation being done in a
Hope fully the title was somewhat descriptive. I have a winform application written in
Sorry about the terrible title. I have a signed assembly 'Signed.dll' that is a
Sorry for the somewhat cryptic title! I'll try to explain. I have the following
Again same question title but requirement is somewhat different. We have implemented push notification
Should be an easy one and might have over complicated the title somewhat. I
I realize that the title may be somewhat confusing, so I apologize. Basically, this
My title is somewhat vague, because I'm not exactly sure how to ask what
Somewhat misleading title, I know. Never actually wanted to store TimeZoneInfo object themselves: rather,
Sorry for the somewhat confusing title. Not sure really how to title this. My

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.