data-access-layer

Designing DAL in .NET to be “data-source independent” and not just “database independent”?

社会主义新天地 提交于 2019-12-11 11:08:42
问题 How to design such flexible DAL (specifically in .NET) ? What interfaces .NET provides and what should be done on my own ? Its a greenfield project starting with SQL Server as data source but in future, parts of it will move to different NoSQL type of datastores. Also, we may need to experiment with lot of different datastores (like some data may have to go with Cassandra, some with RDBMS, some to other DHT etc.) Therefore easily switchable access layer will be needed. All i know right now is

N Tiers with SubSonic 3, Dirty Columns collection is always empty on update

久未见 提交于 2019-12-11 08:18:23
问题 Here is what I am doing, and not working for me. I have a DAL generated with SubSonic 3 ActiveRecord template, I have a service layer (business layer if you well) that have mixture of facade and some validation. Say I have a method on the Service layer like public void UpdateClient(Client client); in my GUI i create a Client object fill it with some data with ID and pass it to the service method and this never worked, the dirty columns collection (that track which columns are altered in order

Are there any gotchas or good reasons not to use autosproc for stored procedure calls?

孤者浪人 提交于 2019-12-11 06:14:38
问题 I've implemented a data access layer that populates generic entities from a datareader using a variation of the third monkey approach (http://www.codeproject.com/KB/database/DynamicMethod_ILGenerator.aspx). This works well, performs well and saves me writing loads of repetetive code for data retrieval. Now I want to add methods that take a generic entity and convert it to a parameter list for feeding to a stored proc so that I can add data persistence to my monkey's trick collection. I found

java data access: is this good style of java data access code, or is it too much try finally?

…衆ロ難τιáo~ 提交于 2019-12-11 01:55:36
问题 Is this good style of java data access code, or is it too much try finally ? public List<Item> getItems() throws ItemException { ArrayList<Item> items = new ArrayList<Item>(); try { Connection con = ds.getConnection(); try { PreparedStatement pStmt = con.prepareStatement("SELECT ...."); try { ResultSet rs = pStmt.executeQuery(); try { while (rs.next()) { Item item = new Item(); item.setItemNo(rs.getString("item_id")); // ... items.add(item); } } finally { rs.close(); } } finally { pStmt.close

MSTest with Moq - DAL setup

感情迁移 提交于 2019-12-10 23:46:04
问题 I'm new to Moq, and just started on a project that's already in development. I'm responsible for setting up unit testing. There's a custom class for the DatabaseFactory that uses EnterpriseLibrary and looks like this: public Database CreateCommonDatabase() { return CreateDatabaseInstance(string.Empty); } private static Database CreateDatabaseInstance(string foo) { var database = clientCode == string.Empty ? DatabaseFactory.CreateDatabase("COMMON") : new OracleDatabase(new ClientConnections()

DAL/BLL and Client/Server: Should the client use BLL or DAL objects for presentation? Or maybe another layer (data transfer object?)

﹥>﹥吖頭↗ 提交于 2019-12-10 23:05:52
问题 I'm writing a client/server system. The server has a DAL/BLL design. The client is responsible for presenting the data objects and providing dialogs and wizard to allow the user to update these objects (i.e. adding/editing a user). Initially I thought I'll just make the DAL objects have a universal data provider object so they can be used by the client as well as the server. For instance, when the data object is being used by the server, the database is the data provider; when the data object

Asp.Net: Returning a Reader from a Class

独自空忆成欢 提交于 2019-12-10 19:16:38
问题 I was just wondering about the correct way to return a reader from a class? My code below works, but I'm unsure if this is correct. Also. I can't close the the connection in my class method and still access it from my ascx page, is that OK? // In my class I have the following method to return the record/reader -- it's a single record in this case. public SqlDataReader GetPost() { SqlConnection conn = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("con_spPost", conn); cmd

Re-factor my DAL code to a Domain Driven Design or more modern design (C# 3.5)?

人走茶凉 提交于 2019-12-10 14:45:27
问题 The development is limited to Visual Studio 2010 (Client approved software). We need to access the data through stored procedures. I want to avoid making it too complex with an aggressive schedule. Most of the design I see involve EF and LINQ, Not sure how to design for procs? I want to create a separate code library project (used Web UI): Application.Domain - Interact get/put stored procedures, entities Application.Web - containing Web UI (JQuery, AJAX), WCF Service Can anyone give me sample

Data Access Layer Static or Instance based?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 13:18:45
问题 My current application is using an instance based data access layer. I instantiate the layer with the connection string. I then call a method that will do some sort of command. For example there is a method that will fill a dataset. Basically, I pass the stored procedure and any SQL parameters and get back a dataset. Is it better to have a static class to handle my data access or an instance based? I do have a Domain layer with objects, but I am not mapping the objects like an ORM would. I am

Seeding EF Database in a Separate DAL Project

独自空忆成欢 提交于 2019-12-10 11:58:48
问题 I'm starting a new ASP.NET project, and I'm trying to follow the multi-project approach I've seen mentioned in multiple questions around Stackoverflow. I've been following this tutorial, but it assumes only one project for your entire solution. Most notably, it recommends modifying your Global.asax file with code to set the database initializer. Seeing as how my DAL project doesn't have a Global.asax file, what is the correct procedure for seeding the initial EF database? 回答1: I stand