UniqueIndexViolationException

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

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

Regards
Mar 6, 2015 at 7: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
Mar 6, 2015 at 7:51 AM
hmmm... where did you find it? which doc? cannot find it
Mar 6, 2015 at 1: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
Mar 6, 2015 at 6:06 PM
Edited Mar 6, 2015 at 6: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 6: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 10:29 PM
I am catching this when i savechanges after adding a new entity with related entities

I am using sql server 2012

Regards
Mar 6, 2015 at 10: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.