codesmithtools / Templates

CodeSmith Generator Templates
http://www.codesmithtools.com/product/generator
54 stars 35 forks source link

PLINQO: Extensions are all generated with duplicate GetByName methods #268

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Just installed Codesmith 5.2 professional
2. Downloaded official PLINQO 4.0.1239 release and extracted to a location.
3. Updated my project's .csp to point to the location in step 2.
4. Updated all projects to reference the new codesmith.data.dll that was 
installed during their 5.2 installation.

What is the expected output? What do you see instead?
I expect to see no errors when compling but I see this instead:

F:\VSTS\Citadel\Code\Libraries\Citadel\Citadel.Data\Queries\SecurityOperati
onsExtensions.Generated.cs(134,65): error CS0111: 
Type 'Citadel.Data.SecurityOperationsExtensions' already defines a member 
called 'GetByName' with the same parameter types

It's complaining about these two methods below which both have the same 
parameter types.

        public static Citadel.Data.SecurityOperations GetByName(this 
IQueryable<Citadel.Data.SecurityOperations> queryable, string name)
        {
            var entity = queryable as 
System.Data.Linq.Table<Citadel.Data.SecurityOperations>;
            if (entity != null && entity.Context.LoadOptions == null)
                return Query.GetByName.Invoke
((Citadel.Data.CitadelDataContext)entity.Context, name);

            return queryable.FirstOrDefault(s => s.Name == name);
        }

        public static IQueryable<Citadel.Data.SecurityOperations> GetByName
(this IQueryable<Citadel.Data.SecurityOperations> queryable, string name)
        {
            return queryable.Where(s => s.Name == name);
        }

Please use labels and text to provide additional information.
Using Visual Studio 2008

Original issue reported on code.google.com by degree45...@yahoo.com on 17 Feb 2010 at 9:58

GoogleCodeExporter commented 9 years ago
All of the generated classes having this problem have a primary key constraint 
on an 
ID column but also a unique constraint on the [Name] column. Somewhere in the 
plinqo 
QueryExtension.Generated.cst template it is (or is not) picking up on this and 
duplicating this method signature. Here is a sample table that is having the 
issue.

CREATE TABLE [dbo].[tbl_User](
    [UserID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](100) NOT NULL,
    [Domain] [nvarchar](100) NULL,
    [Password] [nvarchar](50) NULL,
    [SID] [nchar](50) NOT NULL,
    [CreateDate] [datetime] NOT NULL CONSTRAINT [DF_User_CreateDate]  DEFAULT 
(getutcdate()),
    [IsGroup] [bit] NOT NULL CONSTRAINT [DF_tbl_User_IsGroup]  DEFAULT ((0)),
    [IsDeleted] [bit] NOT NULL CONSTRAINT [tbl_User.DF_User_Deleted]  DEFAULT 
((0)),
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
    [UserID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [UNQ_tbl_User] UNIQUE NONCLUSTERED 
(
    [Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

Original comment by degree45...@yahoo.com on 17 Feb 2010 at 10:47

Attachments:

GoogleCodeExporter commented 9 years ago
We updated the query extension default method names in version 4 and that is 
explained 
here.

http://community.codesmithtools.com/blogs/tdupont/archive/2009/07/28/breaking-ch
ange-
in-plinqo-3-2.aspx

However, we should be detecting duplicate method names to avoid issues like 
this.

Original comment by shannon....@gmail.com on 17 Feb 2010 at 4:33

GoogleCodeExporter commented 9 years ago
When is this getting fixed? Are you able to reproduce this?

Original comment by degree45...@yahoo.com on 10 Jun 2010 at 7:44

GoogleCodeExporter commented 9 years ago
Just downloaded 5.2.1 of codesmith and the latest plinqo templates and this 
issue is still occurring. I guess I’m going to look into switching to the 
Entity Framework because I can't wait another four months for a fix.

IMO I think you are putting too much effort into creating new features and not 
enough into stabilizing these templates. I can't build a retail application 
when the product used for my data layer doesn’t work.. Too bad because this 
really was the best framework I've seen so far.

Original comment by degree45...@yahoo.com on 10 Jun 2010 at 7:58

GoogleCodeExporter commented 9 years ago
Hello,

I was not able to reproduce this error in PLINQO 5.0 
(http://code.google.com/p/codesmith/downloads/detail?name=PLINQO-v5.0.0.1687.zip
&can=2&q=). If you are able to reproduce please let us know and we can enter a 
go-to-meeting session to see what the real issue is because the schema above 
could not reproduce this issue.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 10 Jun 2010 at 3:55