public int CompareTo(IStructureId other) { if (other.IdType != IdType) { throw new SisoDbException(ExceptionMessages.StructureId_CompareTo_DifferentIdTypes); } if (Equals(other)) { return(0); } if (IdType == StructureIdTypes.Identity) { var x = (int?)Value; var y = (int?)other.Value; if (x.HasValue && y.HasValue) { return(x.Value.CompareTo(y.Value)); } return(x.HasValue ? -1 : 1); } if (IdType == StructureIdTypes.BigIdentity) { var x = (long?)Value; var y = (long?)other.Value; if (x.HasValue && y.HasValue) { return(x.Value.CompareTo(y.Value)); } return(x.HasValue ? -1 : 1); } if (IdType.IsGuid()) { var x = (Guid?)Value; var y = (Guid?)other.Value; if (x.HasValue && y.HasValue) { return(x.Value.CompareTo(y.Value)); } return(x.HasValue ? -1 : 1); } return(Sys.StringComparer.Compare(Value.ToString(), other.Value.ToString())); }