data-access-layer

Is there a way to set a calling application execution permissions for a C# library?

I'm creating a DAL for use in multiple applications, but I'm not providing any authorization or authentication to verify that the calling application has the permissions to execute the DAL and access the data i.e. making sure the user only sees the information they are allowed to see, to me this is the responsibility of the business laye...

Architecture question: client REST API's caching solution

I'm implementing a high traffic client web application that uses a lot of REST API's for its data access layer from the cloud database. I said client because it implements REST and not provides it. REST APIs are implemented server side as well as client side and I need to figure out a good solution for caching. The application is runni...

What is the best approach to make data access methods in NHibernate?

For example, I have two classes: Foo and Bar. This classes are mapped to some tables. As for now, I have static methods for each class: Add, Update, Delete, Get. E.g.: public class Foo { private Guid _id; private string _someProperty; static Foo Get(Guid id); static void Add(Foo foo); static void Update(Foo foo); s...

Look-up tables with Linq-to-Sql

Hi all, I'm working on a car dealer website at the moment, and I've been working on a 'Vehicle' model in my database. I've been making extensive use of lookup tables with FK relationships for things like Colour, Make, Model etc. So a basic version could be something like: Vehicle { Id MakeId ModelId ColourId Price ...

Implementing Next/Previous with LINQ to SQL

I have the code below in an attempt to allow the user to "Step Through" the Case Notes in the DB by clicking Next or Previous on the WinForm. It will grab the First Case Note only. What am I doing wrong? There has been numerous edits to this post, I apologize, but in following Jon Skeet's advice I was able to "fix" what was originally ...

when to set up a web service versus just querying the database

Hi, we have several sites for several different clients, each with several different databases. Some of the databases are at client location, some are on our site. I have been tasked with creating a few sharepoint sites that will display information from the databases. Is it okay to call stored procedures from my sharepoint sites? S...

Does a "thin data access layer" mainly imply writing SQL by hand?

When you say "thin data access layer", does this mainly mean you are talking about writing your SQL manually as opposed to relying on an ORM tool to generate it for you? ...

Linq to SQL for a new project

Hi guys I am about to start a new project and am deciding what data access technology I will be using... I really like LINQ to SQL for a variety of reasons but should I start the new project using the Entity Framework instead?? I have this perception that the Entity Framework is more bloated and needlessly complicated, thus accounting...

What is a good query layer to be used when you write your own DAL? Do we need to write our own query processor and query object model?

So, here I am, about to roll my own data access layer. The key features that I needed in my DAL are asynchronous programming model, cloud based databases (eventual consistency, caching, REST protocols etc), multi-valued attributes, retrieving partial objects etc. I need to provide rich support for object oriented access - lists, dictiona...

How can you generically map a DbDataReader to a Castle.Windsor resolved type?

This is confusing me, so this question will probably be confusing. I have a an application that uses implementations of an IJob interface to accomplish different tasks. public interface IJob { int Id { get; set; } string Name { get; set; } void Run(); } I am using the Castle.Windsor.WindsorContainer to resolve these implementa...

Caching Data Access Layer Results

Hi guys I want to do some caching at the data access layer to help boost performance. I have decided that I will use the HTTPContext cache, with an abstraction layer on top so i can switch in and out other caching strategies later on if needed. Basically the cache should be variant, meaning that for each individual method it will cac...

How do you like the data access part (with SQL Server) of Agile Principles, Patterns, and Practices in C#

How do you think about data access code like this: public void AddCusotmer(Cusotmer customer) { //save customer into database ... // save payment type SavePaymentType(customer); //save other data ... } private void SavePaymentType(Customer customer) { if(customer.PaymentType is XXXPayment) { var payment ...

learning ado.net in c# and looking for good code sample

Hi all, I am trying to learn ado.net. I want to see a real project, real code in 3 layes that works well and written well. I underrstand every part seperatly, I cn't get it right how it all work together tthis why I am asking to download 3 layers winform/wpf solution can anyone help? thanks ...

Why put a DAO layer over a persistence layer (like JDO or Hibernate)

Data Access Objects (DAOs) are a common design pattern, and recommended by Sun. But the earliest examples of Java DAOs interacted directly with relational databases -- they were, in essence, doing object-relational mapping (ORM). Nowadays, I see DAOs on top of mature ORM frameworks like JDO and Hibernate, and I wonder if that is really a...

NHibernate removes DAL?

Am I right that using NHibernate (or any other ORM) removes the necessity of DAL? Or not? ...

whats the recommended Data access layer design pattern if i will apply ado entity frame work later?

I am creating a website and using Linq to SQl as a data access layer, and i am willing to make the website can work on both linq to sql and ado entity framework, without changing many things in the other layers: business logic layer or UI layer, Whats the recommended pattern to achieve this goal? can you explain in brief how to do that...

How RIA Services can help me while creating data access and logic layers?

in this answer he said that i can use RIA services while creating my 3 tiers solution, how it can help me and how it can save me time, because when i checked it on msdn i found that RIA is something tied to silver light, while i am creating a normal asp.net website. ...

Calling all database/ ORM/ data access layer experts

Hi guys, I have a little DB challenge for you. Hopefully you can help. The Problem: I need a solution that will allows me to "handle" changes to primary keys/ composite keys. By "handle", I mean I should still be able to perform CRUD operations with little or no code changes. It needs to have minimum hassle from an application/ databa...

Rules Validation on Data or Domain layer?

Hello, I've been reading Pro ASP.NET MVC Framework, Steven Sanderson, and in chapter 11 it discusses data validation. On page 390 we see the section Moving Validation Logic into Your Model Layer. In this section we see, in page 392, some code showing how to implement validation. The code implements a GetRuleViolations() method and the ...

DAL Design/Load methods with NHibernate

public MyClass(int someUniqueID) { using(//Session logic) { var databaseVersionOfMyClass = session.CreateCriteria(/*criteria*/) .UniqueResult<MyClass>(); //Load logic } } The code sample above is my current direction, although I've reached a point where I need a bit of a sanity check. With NHibernate(I'm gree...