AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

PLINQO not supporting the default value of primary keys (i.e. GUIDs) #463

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Here is a simple table definition which specifically defines l_GUID as a row 
guid, not null and with a default value of NewID() and also a column l_created 
with a default value of GetDate():

USE [SG]
GO

/****** Object:  Table [dbo].[location]    Script Date: 07/26/2010 16:03:53 
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[location](
    [l_guid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
    [l_created] [datetime] NOT NULL,
    [l_createdBy] [uniqueidentifier] NULL,
    [l_name] [nvarchar](255) NULL,
    [l_leadTime] [float] NULL,
    [l_sortOrder] [int] NULL,
 CONSTRAINT [PK_location] PRIMARY KEY CLUSTERED 
(
    [l_guid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[location] ADD  CONSTRAINT [DF_location_l_guid]  DEFAULT 
(newid()) FOR [l_guid]
GO

ALTER TABLE [dbo].[location] ADD  CONSTRAINT [DF_location_l_created]  DEFAULT 
(getdate()) FOR [l_created]
GO

2. Use PLINQO r1838 to quickstart a project against this database. VB or C# 
output both exhibit the issue. As per the PLINQO quickstart guide, open the 
resulting solution, set the web app as the starting project and build the code.

3. In the resulting website / webapp create a new web form using a formview 
control. Display just the name column (as an example), connect to a LINQ 
datasource that uses the Location table from the PLINQO datacontext. Set the 
formview to use InsertItem as its default view. Configure the LinqDatasource to 
support insert and remove the select statement.

4. Load the web page, create a new record.

5. Examine the database. The new record is created. l_Created has picked up the 
default value (timestamp). l_GUID is 00000000-0000-0000-0000-000000000000

Why is PLINQO providing a 00000000-0000-0000-0000-000000000000 GUID instead of 
the DB giving NewID?

If I use the FormView_ItemInserting to sneak in before commit and change 
e.Values("l_GUID") = New GUID the value is also lost by the time it gets to the 
database.

What version of the product are you using?

Codesmith Pro 5.2.2 rwv 11517
PLINQO r1838
VS 2010 / SQL 2008

Original issue reported on code.google.com by jpgburgess on 26 Jul 2010 at 3:31

GoogleCodeExporter commented 9 years ago
Hello,

We are looking into adding the appropriate attribute into the metadata class in 
a future release. For now, you can add the correct attribute onto the metadata 
class for this entity and these custom changes will be persisted and give you 
the functionality you are looking for.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 27 Jul 2010 at 3:41

GoogleCodeExporter commented 9 years ago
I was being a spanner in one respect. Using onItemInserting to set 
e.values("GUID") = System.Guid.NewGuid does work.

Still looking forward to the metadata adjustment in future.

Original comment by jpgburgess on 27 Jul 2010 at 9:38

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for the info.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 1 Aug 2010 at 5:07

GoogleCodeExporter commented 9 years ago
reference 
http://community.codesmithtools.com/Template_Frameworks/f/66/t/11928.aspx

Original comment by bniemyjski on 2 Dec 2011 at 8:40

GoogleCodeExporter commented 9 years ago
http://community.codesmithtools.com/Template_Frameworks/f/66/t/10244.aspx

Original comment by bniemyjski on 27 Nov 2012 at 3:40

GoogleCodeExporter commented 9 years ago
http://community.codesmithtools.com/Template_Frameworks/f/66/t/12378.aspx

Original comment by bniemyjski on 27 Nov 2012 at 3:41