Question: I'm using Json.Net to DeserializeObject Json data.

This is my Json

```
string datosContratos = {"Total":1,"Contrato":[{"Numero":1818,"CUPS":"ES003L0P","Direccion":"C. O  ","TextoCiudad":"MADRID","Tarifa":"2"}]}

```

My classes are:

```
public class Contrato
{
    public int Numero;
    public String Cups;
    public String Direccion;
    public String TextoCiudad;
    public String Tarifa;
}

public class Contratos 
{
    public int Total { get; set; }
    public List<Contrato> ListaContratos { get; set; }
}

```

when I deseralize:

```
Contratos contratos = JsonConvert.DeserializeObject<Contratos>(datosContratos);

```

And the result is that contratos.Total is correct (in this case 1) but the `ListaContratos` is null although it should be filled with the data. I don't see the problem!!!

Answer: 
Just `IF(@CustomerID IS NULL)` is enough 

```
IF(@CustomerID IS NULL)
BEGIN
     --insert here..
      INSERT INTO [tblCustomerMaster]
     ([CustomerName]

    VALUES

    (CustomerName)
    SET @CustomerID = Scope_Identity() -- sql server syntax to get the ID after insert..
END 
ELSE
BEGIN
   -- update perhaps..
END

```
You may try like this:

```
if (isnull(@customerID) == 1)
BEGIN
     --Your code
END 
ELSE
BEGIN
   -- code
END

```

Also change this line

```
declare @CustomerID numeric(18,0)= (SELECT distinct [CustomerID] FROM   [tblCustomerMaster]     where CustomerName = @CustomerName)

```

with this:

```
declare @CustomerID numeric(18,0)
(SELECT @CustomerID := [CustomerID] 
 FROM   [tblCustomerMaster]     
where CustomerName = @CustomerName)

```