data-access-layer

Simple Data Access Layer

假装没事ソ 提交于 2020-01-01 01:17:15
问题 Can anyone suggest a simple Data Access Layer (C# .NET)? Not keen on using the Microsoft Application Data Access block, seems very bloated and overkill. Also don't want to use LINQ to SQL for various reasons. I want to build upon this and create our own in-house ORM, again for various reasons. In the past I've always had the Data Access Layer already built so was never involved in building.... 回答1: Here is a complete list: ORM tools ".Net" ADO.NET Entity Framework, Microsoft’s ORM (released

Is List<> better than DataSet for UI Layer in ASP.Net?

梦想的初衷 提交于 2019-12-30 19:52:34
问题 I want to get data from my data access layer into my business layer, then prepare it for use in my UI. So i wonder: is it better to read my data by DataReader and use it to fill a List<BLClasses> or to fill a DataSet and send the DataSet to UI Layer ??. I'm interested in good performance and scalability. 回答1: Your UI layer should be far-removed from your data access strategy - it shouldn't be dealing with raw data. Thus, your UI should communicate solely with your domain objects (directly or

Dal (with Entity Framework) and Model layers into MVC

痞子三分冷 提交于 2019-12-30 11:24:08
问题 First of all , I use EF into Dal layer (separeted project from MVC, same solution). The generated models from EF's EDMX file are the actual models from Model layer?? If so, how do I access these models to work in MVC's View layer? I think it's wrong accessing data layer directly from view to work with these models, and If I make a Model layer with "my models" and translate Dal's models into mine models... it'll be duplicated code. Probably I'm getting something wrong, but most of egs. are

Reuseable ObjectContext or new ObjectContext for each set of operations?

拥有回忆 提交于 2019-12-30 01:31:12
问题 I'm new to the Entities Framework, and am just starting to play around with it in my free time. One of the major questions I have is regarding how to handle ObjectContexts. Which is generally preferred/recommended of these: This public class DataAccess{ MyDbContext m_Context; public DataAccess(){ m_Context = new MyDbContext(); } public IEnumerable<SomeItem> GetSomeItems(){ return m_Context.SomeItems; } public void DeleteSomeItem(SomeItem item){ m_Context.DeleteObject(item); m_Context

How should EntityManager be used in a nicely decoupled service layer and data access layer?

喜你入骨 提交于 2019-12-28 05:54:44
问题 Somewhat related to my other question Should raw Hibernate annotated POJO's be returned from the Data Access Layer, or Interfaces instead? , I am experienced in creation of nicely decoupled layers, but not using Hibernate or J2EE/JPA. I have been looking at documentation and tutorials, and am puzzled about how to use the EntityManger in an elegant way, as it seems it is responsible for both transactions (which I want to do at my service layer) and persistance methods (which I want to keep in

C# abstraction and database layer

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 09:50:57
问题 I am wondering what's a better way to abstract some of this code, into a simple DAL. At this time, I'm just patching the code and don't have time or need yet to use EF, Linq2Sql or any ORM right now. public string GetMySpecId(string dataId) { using (SqlConnection conn = new SqlConnection(this.MyConnectionString)) { conn.Open(); // Declare the parameter in the query string using (SqlCommand command = new SqlCommand(@"select ""specId"" from ""MyTable"" where ""dataId"" = :dataId", conn)) { //

C# Call Oracle Stored Procedure with nested UDT

社会主义新天地 提交于 2019-12-25 04:07:23
问题 Is it possible to call a stored procedure with an nested object as a parameter? For example I have a Person class that has an Address instance. Person p1 = new Person(); p1.Name = "John"; p1.Address = new Adress{Street = “StackOverflow”, App = 3} p1.Age = 20; In the database I have created the user defined types, and the stored procedure that takes as parameter a person_type that contains an address_type. create or replace TYPE Person_TYPE AS OBJECT ( Name VARCHAR2(100), Age NUMBER, OBJ

Unit/Integration tests for DAL and BLL (with lambdas)

陌路散爱 提交于 2019-12-24 16:03:38
问题 My code basically looks like this: Data access contract: public interface IProvideDataAccess<T> where T : Entity { IEnumerable<T> Select(Func<T, bool> condition); void Save(T entity); void Delete(T entity); } Data access layer: public class Db4oProvider<T> : IProvideDataAccess<T> where T : Entity { private IEmbeddedConfiguration _configuration; private string _connectionString; public Db4oAccesDonnees(string connectionString) { _connectionString = connectionString; _configuration =

LINQ support in Enterprise Library Data Access Application Block

孤人 提交于 2019-12-24 03:10:13
问题 Is LINQ support available in the Data Access Application Block. 回答1: I guess the answer is outdated, 5.0 version has support for linq. The following scenarios are supported: Using a DataReader to retrieve multiple rows of data Using a DataSet to retrieve multiple rows of data Executing a command and retrieving the output parameters Executing a command and retrieving a single-value item Performing multiple operations within a transaction Updating a database with data contained in a DataSet

Switch `ConnectionStrings` between local and remote with Linq to SQL

霸气de小男生 提交于 2019-12-24 02:35:12
问题 First, by Remote I mean a central dedicated SQL Server on our Network. By Local I mean a local SQL Express install. My situation is in house only. No cloud services, external sites, etc. My app allows the user to work disconnected but in order to minimize traffic and a few other issues as well I would like to allow them to connect straight to the central server either automatically whenever it is available and/or when they set a setting choosing Central Server. Are setup is quite simple. A