Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3988476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:15:24+00:00 2026-05-20T06:15:24+00:00

Ok… So I have created my model using EF4. Great! I then turned off

  • 0

Ok… So I have created my model using EF4. Great!

I then turned off the code generation and downloaded this extension: http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313
(POCO Entity Generator). Awesome!

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.

Please have a look at the following code and let me know if I am on the right track.

** Sample Code **

Controller:

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

Model:

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

Repository and Interfaces:

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

Any suggestions would be so helpful to me.

Where does the service layer fit in?

What about the AutoMapper? Do I even need to use that now?

Dependency Injection? Anyone care to explain.

Thanks a bunch,
Sam

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:15:25+00:00Added an answer on May 20, 2026 at 6:15 am

    There’s a great article by Scott Allen about Testing Entity Framework 4 – creating the POCO classes is a good first step, but if you want to test you business layer separate from EF you will have to introduce a Unit of Work that coordinates saving state across multiple repositories and allows DI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an element like this: <span class=tool_tip title=The full title>The ful&#8230;</span> This seems
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
CGI.escapeHTML is pretty bad, but CGI.unescapeHTML is completely borked. For example: require 'cgi' CGI.unescapeHTML('&#8230;')
I have been making a wordpress template. i got stuck at some place... the
what about this one: I want to format the currentTime displayed by a videoPlayer
I have the following problem: I am given a tree with N apples, for
I have a MySQL query: SELECT px.player, px.pos, px.year, px.age, px.gp, px.goals, px.assists ,
I am currently running into a problem where an element is coming back from
English is not my native language. I need a software to spellcheck and correct
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.