design patterns - Separating data from the UI code with Linq to SQL entities -


If it is important to use 'away' data from business and presentation layers, then what options or approach can I take? Can SQL Entities Stay in Data Access Layer with My LINQ?

So far, I just seem to repeat sections produced by sqm, and passing those objects to keep the two layers as an appetite instead.

For example, I have a table in books in my DB, if a user is creating a new book through the UI, then the class class created by class class looks like the perfect fit. It is, though, I am tightening my design by doing this.

I have to have all your data entry (in your case LINQ-to-SQL) in a project and its After that I have another business project that uses DataEver project, from which

in your example for books, there will be a book called a book at my business level:

  Public class book {Private IAuthorRespository _authorRepository = New LinqToSqlAuthorRepository (); Private IBookRespository _bookRepository = New LinqToSqlBookRepository (); Public int bookId {get {return _bookId; }} Private int_bookID; Public Virtual String BookName {get; Set;} Public Virtual String ISBN {get; Set;} // ... other properties public book () {// When creating a new book _bookID = 0; } Public Book (Int ID) {// for an existing book _bookID = ID; Weight (); } Secure zero load () {BookEntity book = _bookRepository.GetBook (BookId); BookName = book.BookName; ISBN = book.ISBN; } Save Public Zero () {BookEntity book = MapEntityFromThisClass (); _bookRepository.Save (book); } Public Author GetAuthor () {Return _authorRepository.GetAuthor (); }}  

This means that your UI is completely separate from actual data access and that logic of all your books is intelligently inserted within a class.

You can separate the IOC by separating it with a system like Microsoft Unity or Castle, so that you can get rid of the = new LinuxOSXX; to be written and instead of IoC.Resolve & lt; IBookRepostory & gt; (); Write something on the lines of (depending on your implementation). This means that your Book Class is not bound either with LINQ-to-SQL.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -