<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Muhammd Rehman Tahir</title>
    <description>The latest articles on Forem by Muhammd Rehman Tahir (@muhammd_rehman_tahir).</description>
    <link>https://forem.com/muhammd_rehman_tahir</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3751251%2F174a323b-c142-4dde-bd6a-bc6831f3ddfd.jpg</url>
      <title>Forem: Muhammd Rehman Tahir</title>
      <link>https://forem.com/muhammd_rehman_tahir</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/muhammd_rehman_tahir"/>
    <language>en</language>
    <item>
      <title>How I Fixed "A Possible Object Cycle Was Detected" in ASP.NET Core (And What I Learned About DTOs)</title>
      <dc:creator>Muhammd Rehman Tahir</dc:creator>
      <pubDate>Thu, 16 Apr 2026 04:44:13 +0000</pubDate>
      <link>https://forem.com/muhammd_rehman_tahir/how-i-fixed-a-possible-object-cycle-was-detected-in-aspnet-core-and-what-i-learned-about-dtos-1k4p</link>
      <guid>https://forem.com/muhammd_rehman_tahir/how-i-fixed-a-possible-object-cycle-was-detected-in-aspnet-core-and-what-i-learned-about-dtos-1k4p</guid>
      <description>&lt;p&gt;Yesterday I ran into a classic but dangerous issue while working on an ASP.NET Core API:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;"A possible object cycle was detected"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At first, everything was working fine… until I introduced some additional logic on top of my existing response. Suddenly, my API started failing during JSON serialization.&lt;/p&gt;

&lt;p&gt;After digging deeper, I realized the root cause:&lt;/p&gt;

&lt;p&gt;❌ I was directly returning EF Core entities&lt;br&gt;
❌ Navigation properties created a circular reference&lt;br&gt;
❌ The serializer went into an infinite loop&lt;/p&gt;

&lt;p&gt;The structure looked something like this:&lt;br&gt;
Entity → Navigation → Entity → Navigation → 🔁&lt;/p&gt;

&lt;p&gt;💥 Boom — Object Cycle Error!&lt;/p&gt;




&lt;h3&gt;
  
  
  🔍 How I resolved it:
&lt;/h3&gt;

&lt;p&gt;Instead of sending the full entity graph to the frontend, I:&lt;/p&gt;

&lt;p&gt;✔ Trimmed the entity to only required properties&lt;br&gt;
✔ Broke the circular reference manually&lt;br&gt;
✔ Understood the importance of separating API models from DB models&lt;/p&gt;




&lt;h3&gt;
  
  
  🚀 Key Learning:
&lt;/h3&gt;

&lt;p&gt;This issue made one thing very clear:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;DTOs are not optional — they are essential.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Using DTOs helps you:&lt;br&gt;
✔ Avoid circular reference issues&lt;br&gt;
✔ Keep your API responses clean and controlled&lt;br&gt;
✔ Improve performance&lt;br&gt;
✔ Maintain proper architecture&lt;/p&gt;




&lt;h3&gt;
  
  
  ⚠️ Developer Tip:
&lt;/h3&gt;

&lt;p&gt;If you're exposing EF entities directly in APIs, you're just one change away from breaking your system.&lt;/p&gt;

&lt;p&gt;Think long-term. Avoid quick fixes.&lt;/p&gt;




&lt;p&gt;💬 Have you ever faced this issue in your APIs?&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>webapi</category>
      <category>softwareengineering</category>
      <category>backend</category>
    </item>
    <item>
      <title>I just published my second NuGet package: Rehman.CurrencyTextify.Core</title>
      <dc:creator>Muhammd Rehman Tahir</dc:creator>
      <pubDate>Wed, 11 Mar 2026 17:06:22 +0000</pubDate>
      <link>https://forem.com/muhammd_rehman_tahir/i-just-published-my-second-nuget-package-rehmancurrencytextifycore-5647</link>
      <guid>https://forem.com/muhammd_rehman_tahir/i-just-published-my-second-nuget-package-rehmancurrencytextifycore-5647</guid>
      <description>&lt;p&gt;&lt;strong&gt;This lightweight and flexible package converts money amounts into text for 8 currencies: Dollar, Euro, Pound, Yen, Rupee, Rial, Dirham, and Dinar — now including PKR!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✨ Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Batch processing&lt;/li&gt;
&lt;li&gt;Fuzzy spelling correction&lt;/li&gt;
&lt;li&gt;Custom rounding modes&lt;/li&gt;
&lt;li&gt;Capitalization styles&lt;/li&gt;
&lt;li&gt;Subunit name overrides&lt;/li&gt;
&lt;li&gt;Handling negative amounts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether you’re building financial apps, invoices, or reports, this package makes working with currencies in code fast, simple, and reliable.&lt;/p&gt;

&lt;p&gt;💡 I’d love for you to try it out and share your feedback!&lt;/p&gt;

&lt;p&gt;🔗 Check it out on NuGet : &lt;a href="https://www.nuget.org/packages/Rehman.CurrencyTextify.Core/" rel="noopener noreferrer"&gt;https://www.nuget.org/packages/Rehman.CurrencyTextify.Core/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nuget</category>
      <category>dotnet</category>
      <category>csharp</category>
    </item>
  </channel>
</rss>
