Several unique constrains on a single document in RavenDb -


let's have class:

public class person {    public string name{get;set;}    public string email {get;set;}    public string googleid {get;set;}    public string facebookid {get;set;} } 

if want make email unique use unique constraint bundle.

but want make both googleid , facebookid properties single unique constraint side side email constraint (while non of them id). possible?

use uniqueconstraints bundle:

public class person {    public string name {get;set;}    [uniqueconstraint]    public string email {get;set;}    public string googleid {get;set;}    public string facebookid {get;set;}    [uniqueconstraint]    public string googleandfacebookids { get;set; } } 

just make sure update googleandfacebookids everytime update either googleid or facebookid. doing ended using simple interface on classes did sort of thing:

public interface icombinedconstraints {     string uniqueid { get; set; }     void updateconstraints(); } 

so,

public class person : icombinedconstraints {     public string name{get;set;}     [uniqueconstraint]     public string email {get;set;}     public string googleid {get;set;}     public string facebookid {get;set;}     [uniqueconstraint]     public string uniqueid { get; set; }      public void updateconstraints()     {         uniqueid = googleid + facebookid;     } } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -