structuremap + sharprepository last versions

180 views
Skip to first unread message

Alberto Gonzalez

unread,
Sep 27, 2014, 6:06:28 PM9/27/14
to sharpre...@googlegroups.com

Hi,

 

I have problem to setup sharprepository + structuremap. have you checked with last versions?:

 

I am using new container as objectfactory is deprecated and it doesnt recognize:

 

x.ForRepositoriesUseSharpRepository

 

it also doesnt recognize context.BuildStack.

 

These are errors I get:

 

Error      29           'StructureMap.IContext' does not contain a definition for 'BuildStack' and no extension method 'BuildStack' accepting a first argument of type 'StructureMap.IContext' could be found (are you missing a using directive or an assembly reference?)

 

Error      26           Cannot convert lambda expression to type 'StructureMap.Configuration.DSL.Registry' because it is not a delegate type

 

Error      28           Cannot convert lambda expression to type 'StructureMap.Pipeline.Instance' because it is not a delegate type  

 

Could you advice what is wrong?

 

Programs.cs: Main()

            var container = new Container(x =>

            {

                x.Scan(scan =>

                {

                    scan.Assembly(“Services");                   

                });

 

                x.For<JobsService>().Use<JobsService>();

                x.For<IJobsRepository>().Use<JobsRepository>();

 

                x.For(typeof(IRepository<>))

                                 .Use(context =>

                                 {

                                     var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();

 

                                     return RepositoryFactory.GetInstance(genericArgs[0], repositoryName);

                                 }

                );

 

                x.For(typeof(IRepository<,>))

                                     .Use(context =>

                                     {

                                         var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();

 

                                         return RepositoryFactory.GetInstance(genericArgs[0], genericArgs[1], repositoryName);

                                     }

                    );

 

                x.ForRepositoriesUseSharpRepository();

 

            });

 

            container.AssertConfigurationIsValid();

 

 

Application service:

 

    public  class JobsService

    {

        private readonly IRepository<Jobs, int> _jobsRepository;

 

        public JobsService(IRepository<Jobs, int> repository )

        {

            _jobsRepository = repository;

        }

        public List<Jobs> GetAll()

        {

 

            var rp = new Jobs {Name = "Job1"};

 

           _jobsRepository.Add(rp);

           var a = _jobsRepository.GetAll().ToList();

           return a.ToList();

        }

    }

 

 

 

Do you have simple sample project that you can send or upload that shows a working solution of structuremap + sharprepository for application services and EF and InMemoery repository?

 

Thanks

Jeff Treuting

unread,
Sep 29, 2014, 11:44:53 PM9/29/14
to Alberto Gonzalez, sharpre...@googlegroups.com

That package has not been updated to work with StructureMap 3.  I will work on getting some working code and post it back here for you to use.  Then we will work on getting the NuGet package updated, or a separate one for version 3 depending on the need.

 

Thanks,

 

Jeff

--
You received this message because you are subscribed to the Google Groups "SharpRepository" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharpreposito...@googlegroups.com.
To post to this group, send email to sharpre...@googlegroups.com.
Visit this group at http://groups.google.com/group/sharprepository.
To view this discussion on the web visit https://groups.google.com/d/msgid/sharprepository/01db01cfda9f%244343b640%24c9cb22c0%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

khcha...@gmail.com

unread,
Aug 24, 2015, 3:05:25 AM8/24/15
to SharpRepository, agonz...@gmail.com
Hi,

I'm attempting to use sharprepository with structuremap3.

any update on this?
Message has been deleted

eha...@gmail.com

unread,
Sep 6, 2015, 1:37:07 PM9/6/15
to SharpRepository, agonz...@gmail.com, khcha...@gmail.com
I too am trying to use structuremap and get this error on the server I deploy to, but not on my local machine.

sniperwolfpk5

unread,
Nov 4, 2015, 11:46:19 PM11/4/15
to SharpRepository, agonz...@gmail.com
Yes please need support for latest structuremap with sharprepository

omar....@gmail.com

unread,
Jan 14, 2016, 5:56:40 AM1/14/16
to SharpRepository, agonz...@gmail.com
I upgraded project to StructureMap 4.

here is my fork https://github.com/fiorebat/SharpRepository

btw I hope that my pull request will be accepted and new nuget package will be relased soon https://github.com/SharpRepository/SharpRepository/pull/145

If someone will test it and confirm that is working I will be fantastic.

Regards
Reply all
Reply to author
Forward
0 new messages