I work on blazor application server side I design web API to interact with razor pages
my issue is which is suitable for my scenario
using ado.net or entity framework core
what I try as below :
[Route("GetAllServersDetails")]
public IActionResult GetAllServersDetails()
{
string query = "";
query = "select s.ServerID, s.Server_Name as ServerName,isnull(s.ServerIp,'') as ServerIp,s.ServerTypeId,isnull(st.ServerType,'') as
ServerType,s.OsTypeId,isnull(os.DetailsName,'') as OsType, s.HostedZoneId,isnull(hostedzone.DetailsName,'') as
HostedZone, s.ServerityId, isnull(serverity.DetailsName,'') as Serverity,s.HostedTypeId, isnull(hostedType.DetailsName,'') as HostedType,
isnull(s.ServerRoleId,0) as ServerRoleId,isnull(serverrole.DetailsName,'') as ServerRole,isnull(s.DRRequired,0) as
DRRequiredID,isnull(drrequired.DetailsName,'') as DRRequired,isnull(s.Remarks,'') as Remarks,isnull(s.OwnerFileNo,'') as ownerfilenumber,
s.IsActive from [dbo].[ServerNames] s with(nolock)
inner join [dbo].[ServerTypes] st with(nolock) on st.ServerTypeId=s.ServerTypeId
left join Details os with(nolock) on os.ID=s.OsTypeId and os.HeaderId=12
left join Details hostedzone with(nolock) on hostedzone.ID=s.HostedZoneId and hostedzone.HeaderId=13
left join Details serverity with(nolock) on serverity.ID=s.ServerityId and serverity.HeaderId=14
left join Details hostedType with(nolock) on hostedType.ID=s.HostedTypeId and hostedType.HeaderId=15
left join Details serverrole with(nolock) on serverrole.ID=s.ServerRoleId and serverrole.HeaderId=16
left join Details drrequired with(nolock) on drrequired.ID=s.DRRequired and drrequired.HeaderId=17";
try
{
ICollection
so are using data reader ado.net is best or using entity framework core
some developer tell me why use ado.net it is old technology and this is not good because it open and close connection with every load page and entity framework not do that
are this is correct
if that better or using entity framework core
I depend on code first technology
Result of statement above is 10000 rows as maximum
Anandu G NathPosted Dec 27, 2023, 8:12 AM
@ahmed salah
ADO.Net DataReader is generally faster than Entity Framework when it comes to raw data retrieval due to its lightweight nature. It provides a forward-only, read-only stream of data from the database.
Better you can use ADO.Net DataReader
Sachin SinghPosted Oct 3, 2023, 11:52 AM
If you are havily using Stored procedure and Functions then ADO.NET is good, in some cases linq queries sometimes becomes much lengthy , however you can call SPs with EF also, but i will recomment using Dapper instead of Ado.NET and EF.
Dapper gives you the benefits of both EF (in terms of auto model mapping) and easily call Sps (Ado.Net feature)
Tahir AnsariPosted Oct 3, 2023, 5:33 AM
Whether to use ADO.NET or Entity Framework Core in your scenario depends on several factors, including your project requirements, familiarity with the technologies, and the specific use case. Here are some considerations for both options:
ADO.NET:
Performance Control: ADO.NET offers fine-grained control over database interactions, making it suitable for scenarios where performance optimization is critical. You can write raw SQL queries and optimize data access according to your needs.
Lightweight: ADO.NET is lightweight compared to Entity Framework Core, which can be beneficial if you want to minimize the overhead of an ORM (Object-Relational Mapping) tool.
Existing Skillset: If you or your team are already experienced in ADO.NET, it might be more efficient to continue using it, especially if you're working on a legacy project where a switch to Entity Framework Core would require significant changes.
Entity Framework Core:
Productivity: Entity Framework Core provides a high-level abstraction for working with databases, reducing the amount of boilerplate code needed. This can improve productivity and reduce development time.
Object-Relational Mapping: EF Core allows you to work with your database in an object-oriented manner, which can simplify code maintenance and make it more readable, especially in scenarios with complex data models.
Cross-Platform: EF Core is cross-platform and supports various database providers, making it a good choice if you need to develop applications that run on different platforms and databases.
Code First: EF Core supports a "Code-First" approach, allowing you to define your data model in code and generate the database schema automatically. This can be convenient for rapid development.
Linq Support: EF Core has built-in support for LINQ (Language-Integrated Query), which can simplify querying your database and make your code more expressive.