Hi Gerdus, Ahh.. that was the problem - thanks. James
On Sep 3, 12:34 pm, Gerdus van Zyl <[email protected]> wrote: > As I understand it HasMany looks for the primary key on the class it's > mapping for to determine the parameter type. So on SpatialApplication > the primary key should be on CRN. Is it set up that way? > > > > On Thu, Sep 3, 2009 at 1:06 PM, JamesL<[email protected]> wrote: > > > Hi Gerdus, > > I've tried that (with various combinations of specifying the ColumnKey > > and Index parameters of the HasMany attribute), but still get the > > same error. > > > I've currently worked around the problem by linking the classes via > > primary key Ids instead. However, I'd really like to be able to link > > via the CRN column. > > > Thanks for your input - any further thoughts? > > > James > > > On Sep 3, 11:59 am, Gerdus van Zyl <[email protected]> wrote: > >> I think [HasMany] should look like [ HasMany( typeof(AppAtbs) ) ] > > >> ~G > > >> On Thu, Sep 3, 2009 at 11:28 AM, JamesL<[email protected]> wrote: > > >> > Hi all, > > >> > I have two tables: > > >> > CREATE TABLE [SpatialApplications] ( > >> > [ApplicationId] [int] IDENTITY (1, 1) NOT NULL , > >> > [CRN] [char] (8) COLLATE Latin1_General_CI_AS NOT NULL , > >> > [SRN] [varchar] (50) COLLATE Latin1_General_CI_AS NULL , > >> > [CaseId] [int] NULL , > >> > [EditStatusId] [int] NULL , > >> > ) ON [PRIMARY] > > >> > CREATE TABLE [AppAtbs] ( > >> > [Id] [int] NOT NULL , > >> > [CRN] [char] (8) COLLATE Latin1_General_CI_AS NOT NULL , > >> > [EOIReceived] [datetime] NULL , > >> > ) ON [PRIMARY] > > >> > (PK on SpatialApplication is ApplicationId, while PK on AppAtbs is Id) > > >> > A SpatialApplications record has many AppAtbs records. > > >> > In my (C#) AppAtb class, I've got the relationship set up as > > >> > private SpatialApplication _SpatialApplication; > >> > [BelongsTo("CRN")] > >> > public SpatialApplication SpatialApplication > >> > { > >> > get { return _SpatialApplication; } > >> > set { _SpatialApplication = value; } > >> > } > > >> > and in the SpatialApplication class: > > >> > private IList<CAP_AppAtb> _CAP_AppAtbs; > >> > [HasMany] > >> > private IList<CAP_AppAtb> CAP_AppAtbs > >> > { > >> > get { return _CAP_AppAtbs; } > >> > set { _CAP_AppAtbs = value; } > >> > } > > >> > When I run the application, I'm getting the error "Syntax error > >> > converting the varchar value 'A0000001' to a column of data type int." > >> > when retrieving SpatialApplication records and their AppAtbs records. > > >> > The full logged SQL is: > > >> > SQL: SELECT cap_appatb0_.CRN as CRN__1_, cap_appatb0_.Id as Id1_, > >> > cap_appatb0_.Id as Id1_0_, cap_appatb0_.CRN as CRN1_0_, > >> > cap_appatb0_.EOIReceived as EOIRecei3_1_0_, cap_appatb0_.AppPackSent > >> > as AppPackS4_1_0_, cap_appatb0_.AppReceived as AppRecei5_1_0_, > >> > cap_appatb0_.NSAppPoints as NSAppPoi6_1_0_ FROM AppAtbs cap_appatb0_ > >> > WHERE cap_appatb0_.CRN=? > > >> > Copying this int SQL Query Analyzer and running it with an appropriate > >> > CRN for the parameter placeholder works fine. > > >> > Can anyone enlighten me as to what is going on? > > >> > Thanks, > > >> > James- Hide quoted text - > > >> - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
