data-access-layer

Creating base class for Entities in Entity Framework

℡╲_俬逩灬. 提交于 2019-12-03 20:51:19
I would like to create a base class that is somewhat generic for all of my entities. The class would have methods like Save(), Delete(), GetByID() and some other basic functionality and properties. I have more experience with Linq to SQL and was hoping to get some good examples for something similar in the EF. Thank you. Like this: public abstract class BaseObject<T> { public void Delete(T entity) { db.DeleteObject(entity); db.SaveChanges(); } public void Update(T entity) { db.AcceptAllChanges(); db.SaveChanges(); } } public interface IBaseRepository<T> { void Add(T entity); T GetById(int id);

Business Object DAL design [closed]

北城余情 提交于 2019-12-03 15:21:29
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 11 months ago . When designing business objects I have tried several different methods of writing the data access layer. Some have worked out better than others but I have always felt there must be a "better" way. I would really just like to see the different ways people have handled the DAL in different situations and their opinon of how the technique worked or didn't work

Pros and Cons of using Singleton Pattern in DAL

浪子不回头ぞ 提交于 2019-12-03 14:53:27
问题 I have asked to use singleton pattern implemented DAL, but I think its difficult to pool the connections,use transactions..etc I would like to know the pros and cons and also would like to know the best way to pool the connections as there can be more than 500 concurrent users for the site I am developing. DB Server is Oracle 10g. DAL uses Enterprise library 3.1 回答1: The singleton pattern is great for a DAL -- I use this in my own enterprise web application (hundreds of users and over 2,000

How do I reference the Sqlite db file in the App_Data folder for my ASP.NET Web Application?

别来无恙 提交于 2019-12-03 12:34:35
问题 I'm currently storing my sqlite db file in the App_Data folder as per ASP.NET best pattern and practices. Currently I'm using the following in the webconfig: <connectionStrings> <add name="sqlite" connectionString="Data Source=|DataDirectory|MyDB; Version=3;" /> </connectionStrings> and the following in code: public SqliteDAO(string path) { Connection = new System.Data.SQLite.SQLiteConnection(path ); } //... //where path = |DataDirectory|MyDB It causes sqlite to make a NEW database (with no

I'm having problems understanding IQueryable<T>

无人久伴 提交于 2019-12-03 11:51:43
So I'm trying to understand IQueryable<T> . A tutorial I'm reading suggests using it but not really sure why. The code simply returns some values using LINQ to SQL. I've done this plenty of times in the past, but not using IQueryable<T> Why use it with my functions that return more than 1 value? Here's my code: public IQueryable<Items> GetItems() { return from item in db.Items where item.IsActive == true orderby item.ItemNumber select item; } IQueryable represents the query as an expression tree without evaluating it on the server. This lets you specify further processing before actually

Best designs for breaking down business logic and data layer when they seem to overlap? [closed]

让人想犯罪 __ 提交于 2019-12-03 08:48:24
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . I'm building a MVC web application (using the Spring MVC framework), and I'm a little stumped on the best way to design a particular area. The application has to interact with a series of web services which are not really all that greatly designed, and don't offer much abstraction in and of themselves - basically there is a web service method for each create/update/retrieve/delete

JPA why use createNamedQuery

心已入冬 提交于 2019-12-03 08:12:39
问题 I'm in the processes of changing my DAO layer from using Hibernate API to using a pure JPA API implementation. It looks like the recommended method is to use the createNamedQuery from the entity manager. The named queries are stored in annotations in the model/entity classes. This just not makes sense to me. Why would you define the JPA Queries in the model objects but use them in the DAOs. Wouldn't it make more sense to just use createQuery from within the DAO itself and define the queries

What are the disadvantages of Typed DataSets

血红的双手。 提交于 2019-12-03 07:58:42
问题 I come from a world that favors building your own rather than rely on libraries and frameworks built by others. After escaping this world I have found the joy, and ease, of using such tools as Typed DataSets within Visual Studio. So besides the loss of flexibility what else do you lose? Are there performance factors (disregarding the procs vs dynamic sql debate)? Limitations? 回答1: Typed datasets are by far an upgrade from the world of classic ADO disconnected recordsets. I have found that

Manual DAL & BLL vs. ORM

落花浮王杯 提交于 2019-12-03 07:54:38
问题 Which approach is better: 1) to use a third-party ORM system or 2) manually write DAL and BLL code to work with the database? 1) In one of our projects, we decided using the DevExpress XPO ORM system, and we ran across lots of slight problems that wasted a lot of our time. Amd still from time to time we encounter problems and exceptions that come from this ORM, and we do not have full understanding and control of this "black box". 2) In another project, we decided to write the DAL and BLL

django models = business logic + data access? Or data access layer should be separated out from django model?

你。 提交于 2019-12-03 07:14:11
问题 In Django, the suggested software architecture is to put all business logic and data access in models. But, some colleagues have suggested that the data access layer should be separate from the business logic (business service layer). Their justification is that the data access layer can isolate changes if a different data source is used. They also say that there is business logic that can be in more than one model. But, when I start coding using the separate data access and business logic