Getting 60 Errors From the Generated Code

Feb 20, 2014 at 5:11 PM
Edited Feb 20, 2014 at 5:12 PM
Hi! This looks like a great tool. I used it to generate DTOs for an existing application which runs. Once the code was generated and I built it there were 60 errors. They are all of the following:

Static types cannot be used as parameters
and
static types cannot be used as type arguments...

BTW, I'm using VS2010 sp1

Any suggestions? I would really like to use your tool with our new application.

Thanks!!
Mike Kiser
Coordinator
Feb 20, 2014 at 5:14 PM
Thanks a lot for trying EntitiesToDTOs!

Hmmmm so strange...
Are yout entities declared as static classes?

Could you share one of the lines that gives that error along with the declaration of the parameter type?

Thx


Sent from my Samsung Galaxy S4



Feb 20, 2014 at 5:47 PM
Edited Feb 20, 2014 at 5:50 PM
Hey thanks for the quick reply!

Here is one that gives a static types cannot be used as type argument error


/// <summary>

/// Converts this instance of <see cref="Review"/> to an instance of <see cref="ReviewDTO"/>.

/// </summary>

/// <param name="entity"><see cref="Review"/> to convert.</param>


public static ReviewDTO ToDTO(this Review entity)

ToDTO is is the source of this error

THanks again!
Mike
Coordinator
Feb 20, 2014 at 6:32 PM
Could you share the implementation of Review entity?
Feb 20, 2014 at 7:26 PM
  /// <summary>
    /// Converts this instance of <see cref="Review"/> to an instance of <see cref="ReviewDTO"/>.
    /// </summary>
    /// <param name="entity"><see cref="Review"/> to convert.</param>
    public static ReviewDTO ToDTO(this Review entity)
    {
        if (entity == null) return null;

        var dto = new ReviewDTO();

        dto.ReviewID = entity.ReviewID;
        dto.ProductID = entity.ProductID;
        dto.CustomerName = entity.CustomerName;
        dto.CustomerEmail = entity.CustomerEmail;
        dto.Rating = entity.Rating;
        dto.Comments = entity.Comments;

        entity.OnDTO(dto);

        return dto;
    }
Coordinator
Feb 21, 2014 at 1:20 AM
Edited Feb 21, 2014 at 1:21 AM
Hi! I was asking for the Entity in fact, not the ToDTO method. Could you share Review entity class implementation?
Thanks
Feb 21, 2014 at 5:34 PM
Hi again!

I am a Solution Architect but have never worked with DTOs and want to learn as they seem like the ultimate mechanism to move data across layers. So, I am new to DTOs and I think I messed up here. I wanted to find a good already built sample that I could use your DTO tool on and understand DTOs better. I used the
TailSpin spyworks example in MSDN. BUT there are no entity class in them and when I ran your DTO Tool I am assuming what is giving me the 60 errors :-).
Can you please direct me to an aleady written sample of code where I can rebuild and then run your tool on to study the DTO classes and all that it generates, and run it? Thanks! I would really apprecaite this!

Mike Kiser
Coordinator
Feb 21, 2014 at 6:48 PM
Hi Mike!
I have no examples, this is an often requested thing but I didn't have the time, as soon as I can I will provide it.
In the mean time, you could download the source and check the testing projects, build them, try running the tool, it would be much like an example.
Without looking your Review class implementation the only thing I could ask is: Is Review entity class (the class you implemented with Entity Framework) declared as a static class? That is what the error is saying at least. If so, remove the static keyword from the entities that are declared as static and try running the tool again. Your entities shouldn't be declared as static.
Let me know what you've found.
Fabian