UniqueIndexViolationException

Mar 6, 2015 at 2:52 AM
Is this no longer available?

I see the examples on the documentation but canot use it, What namespace is it in?

Regards
Coordinator
Mar 6, 2015 at 6:47 AM
Sorry, overlooked documentation, will fix it. Yes, the exception is no longer there, now there's only DataAccessException, which has SubType field indicating type of error. For unique index violation, the value should be DataAccessException.SubTypeUniqueIndexViolation (constant defined in exception class).
See TestUniqueKey test in basic tests project.
thanks for pointing this out, will fix documentation
Roman
Coordinator
Mar 6, 2015 at 6:51 AM
hmmm... where did you find it? which doc? cannot find it
Mar 6, 2015 at 12:51 PM
It is in Tutorial Part 4

https://vita.codeplex.com/wikipage?title=Tutorial_Part4_Validation


I am using this
        catch (DataAccessException ex)
        {
            if (ex.SubType == DataAccessException.SubTypeUniqueIndexViolation)
            {
                Status = "Chave da família ou de subfamília duplicada....";
            }
        }
the ex.SubType is always null

Regards
Coordinator
Mar 6, 2015 at 5:06 PM
Edited Mar 6, 2015 at 5:08 PM
how did you find this page? it's long gone and links to it are not available, it is preserved only in page history of codeplex. And of course, whatever is mentioned there is outdated.
As for your code fragment, let me see.... where are you catching this - in business code? this SubType value should be set by Driver. You are using SQLite, right?
Try running TestUniqueKey test and see what's different.
Mar 6, 2015 at 5:11 PM
Using the search.


Ruben Alves

De: [email removed]
Enviado: ‎06/‎03/‎2015 17:06
Para: [email removed]
Assunto: Re: UniqueIndexViolationException [vita:584726]

From: rivantsov

how did you find this page? it's long gone and links to it are not available, it is preserved only in page history of codeplex. And of course, whatever is mentioned there is outdated.
Mar 6, 2015 at 9:29 PM
I am catching this when i savechanges after adding a new entity with related entities

I am using sql server 2012

Regards
Coordinator
Mar 6, 2015 at 9:38 PM
Look at TestUniqueKey method; try running it. It should go OK. There's an explicit check/assert for SubType value in exception in the test code.
Look at entities and Unique attribute - try to spot what's different with your code.
If you can't find anything - just show me the code, entity definitions at least.