1

I'm new to ValueInjecter, I've used it for a week from a sample app. Now this is the code I'm trying using

    public virtual TInput MapToInput(TEntity entity)
    {
        var input = new TInput();
        input.InjectFrom(entity)
            .InjectFrom<NormalToNullables>(entity)
            .InjectFrom<EntitiesToInts>(entity);
        return input;
    }

It was working fine but now all of sudden, input.InjectFrom seems to taking too much time. I'm not quite sure what I messing up here. Can anybody advice thanks in advance.

Update: e.InjectFrom(input)

this is the line thats taking too much time. I've a Status Type and there are more than 10,000 employee records associated to the POCO instanace... I'm using Mapper hoping to map Status only but for some reason its parsing the whole graph. Is there anyone who can tell how to avoid it? my input only has Status fields and doesn't even contain any child list but still Mapper isn't convinced and parse the whole POCO for more than couple of minutes now.

ThomasW
  • 16,981
  • 4
  • 79
  • 106
afr0
  • 848
  • 1
  • 11
  • 29
  • try to use stopwatch or something like dotTrace and you'll know for sure which line in your code is taking to much time – Omu Mar 15 '12 at 19:01
  • @ChuckNorris input.InjectFrom(entity) .InjectFrom(entity) .InjectFrom(entity); this is the line that takes time, I don't know why is that as it works for most of them but for one record it takes quite a long time to come back. – afr0 Mar 16 '12 at 06:54
  • 1
    you can split it into input.InjectFrom(entity); input.InjectFrom(entity); ... etc. – Omu Mar 16 '12 at 08:31
  • @ChuckNorris source.InjectFrom(viewmodel) this is all I'm trying to achieve right now. Status viewmodel only contains 4 propertries whereas Status source contains same properties BUT it also has got an employee list which is actually coming from the EF that I've no control there. For one Status type I've got 10k+ employees. .InjectFrom traverse all the Employee properties of the source too whereas I want it only to map the root level properties i.e Source Status to ViewModel without parsing properties of 10k+ employees hierarchical records. Do ask if you didn't get what I'm saying. – afr0 Mar 16 '12 at 09:07
  • @ChuckNorris I've just confirmed the e.InjectFrom(input); this implementation is causing the performance hit. m at it again – afr0 Mar 16 '12 at 09:24
  • btw, it would be very helpful if you would show your model and viewmodel, also the IdsToTypeIds – Omu Mar 16 '12 at 10:33

1 Answers1

0

according to injection name "IdsToTypeIds" I suppose that it goes into the DB and pulls data, something like Repo.Get<Type>(Id)

if you don't want to traverse some properties you can specify this rule in the Match method

and also injections can receive parameters in the constructor, in case you need any

anyway, the fastest way is to use the SmartConventionInjection and this is what I recommend you to do

just copy it in your solution and use it as you would use the ConventionInjection

Omu
  • 69,856
  • 92
  • 277
  • 407