kulki wrote:
Otis wrote:
kulki wrote:
Hi,
In the generated code it creates constructors based on the Primary Key. For instance I have a User table with primary key SysId then I LLBLGen creates a constructor
User(int sysId)
which is perfectly fine. However I also have a unique key on userId and therefore I would like to create a constructor of the form User(string userId).
Do I need to create this constructor myself or it already created by the generated code.
thanks
The constructor can't be done, say you have a PK of type string and a unique constraint on a field of type string.
2 times the same constructor, which will not compile. Same goes for 2 UC's which are both a string for example, also won't compile.
Therefore the entities have FetchUsingUC<uniqueconstraintfields>(field1, ...) methods, one per UC.
Well Say that a UI programmer wants to create a new instance of the User object based on the UserId. Are you saying that I need to code something like this:
User myUser = User.FetchUsingUC("Thomas");
UserEntity myUser = new UserEntity();
myUser.FetchUsingUCUserID("Bla");
there is no other way to make it work otherwise, as a constructor like:
public UserEntity(string id) {...}
is the same as
public UserEntity(string name) {...}
As a UI programmer I would expect the programmer not to know anything about the Unique Constraints.
If the developer doesn't know what the uniquely identifying PK field(s) are for a given entity he can never fetch an entity whatsoever, unless using a collection fetch and grab the first one. Some information is ESSENTIAL for developing software. Not allowing developers to have that information is limiting developers writing good software.