Tracking Data Changes in C# .NET

  Рет қаралды 50,199

Hassan Habib

Hassan Habib

Күн бұрын

Пікірлер: 69
@fieryscorpion
@fieryscorpion Жыл бұрын
My goodness, how on earth I did not know about this amazing feature until now! Thank you for the excellent video, Jason Momoa!
@HassanHabib
@HassanHabib Жыл бұрын
It's JSON* :-)
@Tymonello
@Tymonello Жыл бұрын
Holy macaroni, that is so amazing. I've been doing that manually, with like one ID for db record, another ID to share between historical objects, and a flag IsHistorical, and while updating an object, then manually copying it, and adding a new one with edited data... this will save me lots of time!
@HassanHabib
@HassanHabib Жыл бұрын
This one-liner will take care of that! best of luck!
@jwcodendaal
@jwcodendaal Жыл бұрын
Temporal tables are great. I use them when I can. One important note is it requires SQL 2016. In a lot of our CMS systems database compatability is quite old (pre 2016) and we tend to use triggers and audit tables for this kind of thing, very manual compared to temporal tables. Great video. Thanks.
@christiantricarico
@christiantricarico Жыл бұрын
Discovering your channel was a gift on this last day of 2022. Temporal table is a great feature. I'm a .NET developer since 2006 and I really would like to share my knowledge with others and I really like your style. Hope to find the way in the new year 😀
@HassanHabib
@HassanHabib Жыл бұрын
Hey, thanks for your kind words. Would love to have you come on my channel so I can introduce you to my followers/subscribers and hopefully it will be a great start for you to share you knowledge with the world.
@linguini6232
@linguini6232 Жыл бұрын
Super cool that you have a fundraiser attached to this! What an awesome way to give back to a meaningful cause.
@HassanHabib
@HassanHabib Жыл бұрын
This the best thing that happened since I started this channel. I'm really happy I can maximize the benefits people get from this content. Thank you for your kind words.
@bahtiyarozdere9303
@bahtiyarozdere9303 Жыл бұрын
Eye opening! I have been working with Sql Server and dotnet since 2004. I had no idea there is this feature. We were building custom approaches instead. Thank you!
@thanzeeljalaldeen
@thanzeeljalaldeen Жыл бұрын
this was what i was searching for a project im working on. i implemented this and most of the extra code we had to write was cleaned immediatly. this is great! thanks for the great insight!
Жыл бұрын
Great video! I liked this feature because it's a clean way to track data changes. It helps you to keep your code less complex.
@mohamedeffat54
@mohamedeffat54 Жыл бұрын
Is it just me or is this feature is so amazingly critical that I don't know how the majority of SQL databases I've seen out there live without it, interestingly Postgres does not (yet) officially support this feature. I cannot get think of any business no matter large or small that would explicitly opt out of the history and protection this feature gives. Thanks for the introduction to this 🙏
@lucabriguglia
@lucabriguglia Жыл бұрын
Exceptional! I used a kind of event sourcing approach to do basically the same. How on earth I did not know this was supported out of the box!
@sherifezzat4983
@sherifezzat4983 Жыл бұрын
Oh my! This is amazing, brother! Let me share my experience with you! We have some old system that we had to code almost the same thing ourselves, by setting a trigger on the main table in DB on update to copy the old data from the main table to another history table i.e h_original_table_name, the history table contains old data, new data, user, hist_dt, and we used this to build a complete an e2e audit and traceability system, plus recovering from failures as you mentioned in the wonderful explanation! 👍 thanks ❤️
@minimalist_zero
@minimalist_zero Жыл бұрын
I had no idea something like this existed. Thank you very much for this.
@E_G_
@E_G_ Жыл бұрын
This quick sessions&features are great to follow, thank you ☺
@HassanHabib
@HassanHabib Жыл бұрын
Thank you for watching!
@marna_li
@marna_li Жыл бұрын
The PeriodStart and PeriodEnd are Shadow Properties in the model. I think that you can access them in queries using a method in the EF class to represent them. Like this: var contacts = context.Contacts.OrderBy(contact => EF.Property(contact, "PeriodStart")); But true, they are normally are not added to the entity for obvious reasons.
@HassanHabib
@HassanHabib Жыл бұрын
Good point. thank you.
@BlazorPlate
@BlazorPlate Жыл бұрын
Wow! Why we didn't know about this until now. We are gonna apply this concept to our boilerplate SaaS template.
@DavidSmith-ef4eh
@DavidSmith-ef4eh 2 ай бұрын
Implemented something like this myself, but better. All column diffs get saved as json into one column, you get date when it was change and admin id, to know who changed it. If you have data changes which you want to track, you usually want to know who triggered the change. specially if you expose an admin backend.
@mizanrahman7287
@mizanrahman7287 Жыл бұрын
This feature looks like Modified Trigger in SQL Server inserted and deleted table. Excellent job!.
@HassanHabib
@HassanHabib Жыл бұрын
Thank you!
@hutchm92
@hutchm92 7 ай бұрын
Excellent information and thanks for sharing. I’m looking to potentially change what I have or use this for another application.
@shawn301287
@shawn301287 Жыл бұрын
Lovely!! You are making my life easy, one line of code at a time..
@akshay_zz
@akshay_zz Жыл бұрын
Saw two videos of yours. Learned two new things. Thanks
@soucianceeqdamrashti8175
@soucianceeqdamrashti8175 Жыл бұрын
This was a really good tutorial, learned a lot! Nice work Hassan!
@loam
@loam Жыл бұрын
Woah, guess I fiound one more channel to become my favourite C# channel amongst a few others 🙂
@cdrbvgewvplxsghjuytunurqwfgxvc
@cdrbvgewvplxsghjuytunurqwfgxvc Жыл бұрын
Thanks, and also for your work on odata!
@jlzsantos
@jlzsantos Жыл бұрын
Very cool, It's a good example, thanks for sharing.
@fahimahmedali
@fahimahmedali Жыл бұрын
That's an amazing feature. Learned something new today.
@GameDevNerd
@GameDevNerd Жыл бұрын
I just started encountering this channel on YT, hadn't heard of it before, but it seems to cover some "big data" and "enterprise" scenarios I'm not familiar with and would seriously enjoy learning. I've been programming for a long, long time but I couldn't possibly (ever) learn _everything_ haha, nobody can. And there's something about listening to another engineer with expertise in other fields talking about how they do things and solve problems that I just _really_ love and admire. Looks like I found another good channel to add to my "backlog" for future YT-watching sprints, haha 😁 I really, _really_ wanna find time to start making serious videos of my own, because I have a _lot_ of things I could share to add value to people's careers, education and learning paths, etc, but my actual work for my real job keeps me so busy that it's hard to set aside time and ever make myself record and edit! And I've been promising friends and colleagues for a while I was gonna do it ... people want me to make videos about advanced interop and writing wrapper libraries, "hacking" .NET assemblies and using IL and native asm for cool stuff, creating DSLs and lexer/parser/compiler tools, real-time 3D stuff with DirectX 12 and game engine architecture, there's like 100 things I kinda "owe" people videos on, lol. This video gave me a bit more inspiration to get to it today ... I've gotta start soon!!! 🤨
@HassanHabib
@HassanHabib Жыл бұрын
Hi Aaron, we could start doing sessions together - I don't edit my videos, it comes as is. I usually tell people there are content creators and there are people who just make content - I'm the latter haha. Let's find time to get to know each other and show the world some of your magic.
@GameDevNerd
@GameDevNerd Жыл бұрын
@@HassanHabib that would be cool, man, I'd definitely enjoy that. You on Discord?
@HassanHabib
@HassanHabib Жыл бұрын
@@GameDevNerd Of course, this is my Discord: Hassan Habib#8097
@billias28
@billias28 4 ай бұрын
Very nice presentation
@Ferenc-Racz
@Ferenc-Racz Жыл бұрын
Thank you for this video. Thank you for your knowledge sharing! I appretiate it.
@ThiagoCoppi1
@ThiagoCoppi1 Жыл бұрын
Amazing feature man! Thanks for sharing!
@abdchuhan
@abdchuhan Жыл бұрын
That works only for MS SQL Server, for other databases you have to do this Audit manually.
@Albertkallal
@Albertkallal Жыл бұрын
Only thing to add is that you can add + create a temporal table for any table - and that includes when you not using EF and a database first approach as in this video. So, even if you using an existing web site, or even say ms-access against a sql server table, you can add + enable a temporal table, and no code changes are required at the code level, or even if 2 different systems use the same database. so, to be clear, this is a SQL server feature, and one that not really tied to code or even when using a database model - no requirement exists to use this feature with models - it works even if using say ODBC to sql server.
@awaisshabir9169
@awaisshabir9169 Жыл бұрын
Wonderful session
@felipesakuma9882
@felipesakuma9882 Жыл бұрын
I tried creating a column for LastModifiedBy and OperationDone using Entity Framework but couldn't make it work. Am I missing something or it is impossible to do so with EF only? I understand it is possible doing so with custom methods that write to a history table, but I prefer using native code from EF
@mohammedelsuissey1745
@mohammedelsuissey1745 Жыл бұрын
Hello Hassan Great work man, thanks BTW, ef.tools package includes the ef.design package :)
@HassanHabib
@HassanHabib Жыл бұрын
I see. Thank you!
@anilkumar8753
@anilkumar8753 Жыл бұрын
Temporal tables not available in SQL server standard edition.
@maltebeck514
@maltebeck514 Жыл бұрын
Hey, nice video! Is there an equal simple way to create a „bitemporal“ table? That means track not only date of change, but also date of knowledge, so you know which history was known at a given date?
@HassanHabib
@HassanHabib Жыл бұрын
Please elaborate. I don't fully get what you're asking.
@bhatsanket
@bhatsanket Жыл бұрын
What about turning on CDC... This way the orm is not burdened with this?
@zimcoder
@zimcoder Жыл бұрын
How would you take advantage of this if you are using the repository pattern on top of EF?
@CesarBonezzi
@CesarBonezzi Жыл бұрын
Hassan, Thanks very much for this excellent introduction of Temporal Tables in EF. I will be exploring this further in the next couple of days. First, I was wondering if you come across anything about the performance hits from temporal tables to the system. And second, in a system that is of high traffic generating many entries on the temporal table, how are these managed in terms of how much space they occupy, and is it possible to compress the temporal table, to minimize storage usage.
@HassanHabib
@HassanHabib Жыл бұрын
Hi Cesar, Thank you for your kind words. I appreciate you. I haven't analyzed the performance for Temporal Tables yet - might be a good session to do however.
@razbasnet173
@razbasnet173 Жыл бұрын
Holly shit thank you for sharing.😊
@GarethDoherty1985
@GarethDoherty1985 Жыл бұрын
Is there a way for it to also track who changed the data?
@HassanHabib
@HassanHabib Жыл бұрын
If you add fields like CreatedBy and UpdatedBy you certainly could.
@mahmoudakeel8246
@mahmoudakeel8246 Жыл бұрын
What is the best monitor for developer from your opinion?
@HassanHabib
@HassanHabib Жыл бұрын
I like this one: SAMSUNG 49” Odyssey G9 Gaming Monitor
@james69911
@james69911 Жыл бұрын
good job! amazing function, and I wonder if i update student by using raw sql command, will this function still can track data changes? thank you for sharing this information.
@HassanHabib
@HassanHabib Жыл бұрын
Yes it should - give it a shot
@petargeorgiev2738
@petargeorgiev2738 Жыл бұрын
Is this killer of Event Sourcing?
@karthiks4347
@karthiks4347 Жыл бұрын
Well, i think the dates are not coming because the students class has no columns for dates. I think we must inherit the students class into a new class having both the date columns that is used to iterate though!! My hunch is, this may work.
@yaKaiZen
@yaKaiZen Жыл бұрын
🙏
@prithvisingh2593
@prithvisingh2593 Жыл бұрын
wonderfull
@akhilbandari629
@akhilbandari629 Жыл бұрын
Great to know
@novaploca2080
@novaploca2080 Жыл бұрын
Wow
@TheZigsDk
@TheZigsDk Жыл бұрын
Jesus christ, can I buy you a coffee or something?
@HassanHabib
@HassanHabib Жыл бұрын
Give it to the very first homeless person you run into tomorrow (I used to be homeless)
@bootsector13
@bootsector13 Жыл бұрын
give it to me
@ed-ou812
@ed-ou812 Жыл бұрын
Don’t lock it down to students. Make this a generic solution to data changes so it is easily reusable.
Enabling Fuzzy Search in C# .NET
9:54
Hassan Habib
Рет қаралды 21 М.
How to connect C# to SQL (the easy way)
1:20:40
IAmTimCorey
Рет қаралды 1,1 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 1,4 МЛН
ЗНАЛИ? ТОЛЬКО ОАЭ 🤫
00:13
Сам себе сушист
Рет қаралды 4,2 МЛН
Which team will win? Team Joy or Team Gumball?! 🤔
00:29
BigSchool
Рет қаралды 15 МЛН
Entity Framework Core 6 - Easy Audits with Temporal Tables
26:42
Programming with Felipe Gavilan
Рет қаралды 7 М.
Settling the Biggest Await Async Debate in .NET
14:47
Nick Chapsas
Рет қаралды 146 М.
ResourceSaver/Loader Tutorial Godot 4 + Devlog 4
13:36
Ponyboy Studios
Рет қаралды 114
Don't Use AutoMapper in C#! Do THIS Instead!
16:17
Codewrinkles
Рет қаралды 70 М.
C# Data Access: Complex Objects with Dapper
28:09
IAmTimCorey
Рет қаралды 31 М.
C# Entity Framework - More Advanced Topics on EF Core 5
1:25:02
Rainer Stropek
Рет қаралды 19 М.
Using EF Core’s Coolest Feature to Audit in .NET
26:06
Nick Chapsas
Рет қаралды 37 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 261 М.