c# - Compare List of Integers and add/remove the rows in database using the difference in result LinqtoSQL -


currently i'm working on project using linqtosql , simpler solution current problem.

example: lets got table named example 3 rows (with values 1,2,4) in code(c#) got these values list of integer(lets name lstexisting) in method got list of integer ( lstcurrent) integers values (1,2,3) want compare both list , find difference of integers , update database, according example new row value 3 should added , existing row value 4 should deleted. ps:(the integer values unique , 1,2,3,4) linq solutions preferable don't mind other easier solutions.

thanks

you need find new items , deleted items using except like:

var newitems = lstcurrent.except(lstexisting).tolist(); var tobedeleteditems = lstexisting.except(lstcurrent).tolist(); 

later can iterate each list , add/delete accordingly.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -