jeudi 26 décembre 2019

How to verify relational record inserted or not from c# list

This is testing approach task,

I have List<Customers>, let's assume customer list have 10 records and all customer have 3 orders, ( please note in real requirement, there can be n records and it may be x orders).

public class Customers
{
  public int CustomerId {get;set;}
  public int CustomerTableXYZUniqueId {get;set;}
  public List<orders> orders{ get; set; }
}

public class Orders
{
  public int OrderId {get;set;}
  public int CustomerId {get;set;}
  public int OrderTableXYZUniqueId {get;set;}
  public List<orders> orders{ get; set; }
}

so total 30 rows will be enter across 2 tables. parent Table : customer child Table : order

Now in C#, I need to execute a SQL query, which will guarantee me that all 30 rows records have been entered in.

What query should I write in SQL to verify that all records are inserted in 2 tables?

parent Table : customer
child Table : orders

Maybe something like this, but not sure:

select * from customer as poh  join
orders as poL customer.customerId  = orders.customerId 
where customer.CustomerTableXYZUniqueId in ( "172772,18282881,28282818")
and orders.orderTableXYZUniqueId in ('37371', "182882");

do you have suggestion please?

Edit1 :

What i am trying to do is, i'm sending List to some POST API call, when API call returning me success, i want to run some kind of sql script via c# which will make sure that records are entered with exact fields value.

here in this example, i have chosen fields property are Customer/OderXYZUniqueId,

So i will read Customer/OderXYZUniqueId values and include in SQL query and see if records are inserted or not.

Aucun commentaire:

Enregistrer un commentaire