Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

does record exist in table

$
0
0

Is there a way using LINQ to see if a record exist in a table, if not, do an insert from another table?

Example:

Table 1 looks like this:

Sales table in production
id
salesid
Location
SalePrice
SalesPerson


Staging table for uploaded data
id
Salesid
Location
SalesPrice
SalesPerson

The staging table is populated from a text file that user uploads and they can make some changes on the web page. If the SalesId exists in the sales table, then it's not inserted from the staging table, if it doesn't exist, then insert the record from the staging table to the sales table, and so on 


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>