» »

[SQL, C#] Več kot en data provider

[SQL, C#] Več kot en data provider

dprc ::

Torej, če želim v aplikaciji omogočiti uporabo več data providerjev (npr. MySQL, Oracle, SqlServer, SqlCE...)
mi za to .NET brez problema omogoča ustvarjanje abstraktnega objekta (IDbConnection, IDbCommand...) in nato konkreten object, ki je odvisen od izbire data providerja. OK.
Kako pa je potem z komandami, nima vsak provider malce drugačen SQL? Brskal sem že po internetu pa na najdem dovolj podatkov v zvezi s tem. Dvomim, da moram za vsakega providerja pisati posebej komande in jih nato glede na izbiro vstavljati v Command. S tem bi bilo preveč 'klobasanja'.
Trenutni query-ji recimo, ki so napisani za SQL Server, ne bodo delovali na Oracle bazi...

cekr ::

Malo si poglej, kako deluje LINQ, Linq2Entity in podobne reči.
Sinclair ZX Spectrum [Zilog Z80A - 3.5 MHz, 48kB, dvojni kasetofon,
TV-OUT, radirke, Sinclair-Basic], Sinclair ZX-81 [Z80A, 3.25MHZ, 1kB]

elrado ::

Dobi si nek ORM za .NET, ta za vse to poskrbi sam. Ti moraš samo priskrbeti povezave do baze (konfiguracija) in napisati objektno kodo za manipulacijo s podatki.

List of object-relational mapping software @ Wikipedia

Zgodovina sprememb…

  • spremenil: elrado ()

dellon ::

Priporočam Nhibernate

bedak ::

sej maš entity framework ...

dprc ::

Odlično, to sem iskal (ORM). Hvala vsem :)

sebastjan28 ::

Osebno bi ti tudi priporočal, da si prebereš kaj na temo The Repository Pattern

Link

Context
In many applications, the business logic accesses data from data stores such as databases, SharePoint lists, or Web services. Directly accessing the data can result in the following:
Duplicated code


    A higher potential for programming errors
    Weak typing of the business data
    Difficulty in centralizing data-related policies such as caching
    An inability to easily test the business logic in isolation from external dependencies



Objectives

    Use the Repository pattern to achieve one or more of the following objectives:
    You want to maximize the amount of code that can be tested with automation and to isolate the data layer to support unit testing.
    You access the data source from many locations and want to apply centrally managed, consistent access rules and logic.
    You want to implement and centralize a caching strategy for the data source.
    You want to improve the code's maintainability and readability by separating business logic from data or service access logic.
    You want to use business entities that are strongly typed so that you can identify problems at compile time instead of at run time.
    You want to associate a behavior with the related data. For example, you want to calculate fields or enforce complex relationships or business rules between the data elements within an entity.
    You want to apply a domain model to simplify complex business logic.


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Win 7?

Oddelek: Operacijski sistemi
91704 (1394) feryz
»

Nakup iPhona iz tujine-rabim vaše mnenje :)

Oddelek: Loža
72999 (2820) Thagirion
»

wiki > pdf

Oddelek: Programska oprema
8981 (814) CaqKa
»

Dober posel

Oddelek: Loža
51185 (1094) Spajky

Več podobnih tem