Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework 4 POCO Generation
    primarykey
    data
    text
    <p>Ok... So I have created my model using EF4. Great!</p> <p>I then turned off the code generation and downloaded this extension: <a href="http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313</a> (POCO Entity Generator). Awesome!</p> <p>Ran it, and it generates all of my classes. Is that all I have to do? It seems to work, my repositories get to the objects and persist to the DB.</p> <p>Please have a look at the following code and let me know if I am on the right track.</p> <p>** Sample Code **</p> <p>Controller:</p> <pre><code>Namespace Controllers Public Class HomeController Inherits System.Web.Mvc.Controller Function Index() As ActionResult Return View(New Models.HomeModel) End Function End Class End Namespace </code></pre> <p>Model:</p> <pre><code>Namespace Models Public Class HomeModel Private _Repository As Titan.Business.Repositories.ICustomerRepository Private _SalesRepRepo As Titan.Business.Repositories.ISalesRepresentativeRepository Public Property Customers As IEnumerable(Of Titan.Business.Customer) Public Property SalesReps As IEnumerable(Of Titan.Business.SalesRepresentative) Public Sub New() _Repository = New Titan.Business.Repositories.CustomerRepository _SalesRepRepo = New Titan.Business.Repositories.SalesRepresentativeRepository _Customers = _Repository.Query(Function(x) x.LastName.StartsWith("Str")) _SalesReps = _SalesRepRepo.Query(Function(x) x.LastName.StartsWith("Str")) End Sub End Class End Namespace </code></pre> <p>Repository and Interfaces:</p> <pre><code>Namespace Repositories Public Interface IRepository(Of T) Function Query(ByVal Predicate As System.Linq.Expressions.Expression(Of Func(Of T, Boolean))) As IEnumerable(Of T) Function GetByID(ByVal ID As Integer) As T Sub Add(ByVal Entity As T) Sub Delete(ByVal Entity As T) Sub Save(ByVal Entity As T) End Interface Public Interface ICustomerRepository Inherits IRepository(Of Customer) End Interface Public Interface ISalesRepresentativeRepository Inherits IRepository(Of SalesRepresentative) End Interface End Namespace Namespace Repositories Public Class SalesRepresentativeRepository Implements ISalesRepresentativeRepository Public Sub Add(ByVal Entity As SalesRepresentative) Implements IRepository(Of SalesRepresentative).Add End Sub Public Sub Delete(ByVal Entity As SalesRepresentative) Implements IRepository(Of SalesRepresentative).Delete End Sub Public Function GetByID(ByVal ID As Integer) As SalesRepresentative Implements IRepository(Of SalesRepresentative).GetByID End Function Public Function Query(ByVal Predicate As System.Linq.Expressions.Expression(Of System.Func(Of SalesRepresentative, Boolean))) As System.Collections.Generic.IEnumerable(Of SalesRepresentative) Implements IRepository(Of SalesRepresentative).Query Using db As New GTGContainer Return db.SalesRepresentatives.Where(Predicate).ToList End Using End Function Public Sub Save(ByVal Entity As SalesRepresentative) Implements IRepository(Of SalesRepresentative).Save End Sub End Class End Namespace </code></pre> <p>Any suggestions would be so helpful to me.</p> <p>Where does the service layer fit in?</p> <p>What about the AutoMapper? Do I even need to use that now?</p> <p>Dependency Injection? Anyone care to explain.</p> <p>Thanks a bunch,<br> Sam</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload