Parameters not generated

Feb 8, 2009 at 10:17 PM

I am using the last changeset (30491) but when i generate the repository classes the select (GetOne) command doesn't generate the parameter for the UserId.


Below the generated DbCommand for GetUserByUserID.

public
DbCommand ConstructSelectCommand(Database db, System.Int32 userId)

 

{

 

 

DbCommand command = db.GetStoredProcCommand("GetUserByUserId");

 

 

 

return command;

 

}

Can some one tell me what is going wrong?

Feb 21, 2009 at 5:34 PM
problem found in EntitySelectionFactory.cs.t4.

the command from the repository factory for vs2005 was changed by someone as shown below

//foreach(PropertyParameterMapping parameterMapping in identity.ParameterMappings)
foreach(PropertyParameterMapping parameterMapping in storedProcedureMapping.ParameterMappings)

The //foreach(PropertyParameterMapping parameterMapping in identity.ParameterMappings)

should not have been removed. the command should have stayed:

 

foreach(PropertyParameterMapping parameterMapping in storedProcedureMapping.ParameterMappings)

Mar 24, 2009 at 8:13 PM
Hey,

I am having this same issue.  I am using Changeset 28019  I am a little confused how you fixed the problem.  In EntitySelectionFactory.cs.t4 the code currently reads:

//foreach(PropertyParameterMapping parameterMapping in identity.ParameterMappings)

foreach(PropertyParameterMapping parameterMapping in storedProcedureMapping.ParameterMappings)

{

Should this be changed to this?

foreach(PropertyParameterMapping parameterMapping in identity.ParameterMappings)

//foreach(PropertyParameterMapping parameterMapping in storedProcedureMapping.ParameterMappings)

{

Please clarify it would help me a great deal.

Mar 24, 2009 at 9:01 PM
Ok I made the change in my above post and it is correctly adding the parameters.  Now.... This is the problem.

It generates this method:

///

 

<summary>

 

 

/// Construct a Aggregators object from OUT and IN/OUT parameters.

 

 

/// </summary>

 

 

internal sealed class GetAggregatorsByCustomerIdFactory : ISimpleDomainObjectFactory<Aggregators>

 

{

 

public Aggregators Construct(Database db, DbCommand command)

 

{

 

Aggregators aggregators = new Aggregators();

 

aggregators.Address =

CastDBValue.ToRequired<String>(db, command, "Address");

 

aggregators.Address =

CastDBValue.ToRequired<String>(db, command, "ContactAddress");

 

aggregators.Address2 =

CastDBValue.ToRequired<String>(db, command, "Address2");

 

aggregators.Address2 =

CastDBValue.ToRequired<String>(db, command, "ContactAddress2");

 

aggregators.AggregatorId =

CastDBValue.ToRequired<Int32>(db, command, "AggregatorId");

 

aggregators.AggregatorName =

CastDBValue.ToRequired<String>(db, command, "AggregatorName");

 

aggregators.AlternatePhone =

CastDBValue.ToRequired<String>(db, command, "AlternatePhone");

 

aggregators.City =

CastDBValue.ToRequired<String>(db, command, "City");

 

aggregators.City =

CastDBValue.ToRequired<String>(db, command, "ContactCity");

 

aggregators.ContactPerson =

CastDBValue.ToRequired<String>(db, command, "ContactPerson");

 

aggregators.ContactState =

CastDBValue.ToRequired<String>(db, command, "ContactState");

 

aggregators.ContactTitle =

CastDBValue.ToRequired<String>(db, command, "ContactTitle");

 

aggregators.ContactZip =

CastDBValue.ToRequired<String>(db, command, "ContactZip");

 

aggregators.CustomerId =

CastDBValue.ToRequired<Int32>(db, command, "CustomerId");

 

aggregators.DeliveredkW =

CastDBValue.ToOptional<Nullable<Double>>(db, command, "DeliveredkW", null);

 

aggregators.Phone =

CastDBValue.ToRequired<String>(db, command, "Phone");

 

aggregators.State =

CastDBValue.ToRequired<String>(db, command, "State");

 

aggregators.Zip =

CastDBValue.ToRequired<String>(db, command, "Zip");

 

 

return aggregators;

 

}

}

But the stored procedure just returns a result set.  CastDBValue has an overload to use a datareader instead of a dbcommand, im going to check into that.

Is there a more stable release for 2.0 that I should be using?  This one seems to be right in the middle of development.

Mar 24, 2009 at 10:26 PM
Basically after a bit of research I found that the stored procedures generated are not compatable with the code that is generated.  As far as I can tell this is true of the latest build.