Hi Guys,
I found documentation for custom persistence mapping by overriding the “OnModelCreating” method. I am not sure on how to implement this using LLBLGen Pro.
This is the problem I am trying to solve..
When a user logs on to my application, a set of views are presented to user based on their login. My views are named like so:
• 3050_CUSTOMER_VIEW
• 3050_ORDERS_VIEW
• 3051_CUSTOMER_VIEW
• 3051_ORDERS_VIEW
If customer 3050 logs in, the model should map to the 3050 views and if the customer is 3051, the underlying map should map to the 3051 views. If you use the “OnModelCreating” method you should be able to do something like the following:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
...
var customer = ((PORTAL_USERS)e).Cusotmer; //Not sure how to do this yet..??
switch (customer)
{
case 3050:
modelBuilder.Entity<Generic_View>().MapSingleType().ToTable("3050_CUSTOMER_VIEW ");
break;
case 3051:
modelBuilder.Entity<Generic_View>().MapSingleType().ToTable("3051_CUSTOMER_VIEW ");
break;
}
}
I have a few questions:
- Is there an easier way to implement what I am trying to do in LLBLGen Pro?
- Where is the LLBLGen Pro equivelant of "OnModelCreating"?
- How can I implement the above in LLBLGen Pro?
- I have a custom Authentication Service that looks like the following:
public class AuthenticationService : IEntityLoginManager
{
public IPrincipal Login(ILoginCredential credential, EntityManager entityManager)
{
UserIdentity identity = null;
if (credential == null)
{
throw new LoginException(LoginExceptionType.NoCredentials, "No Credentials");
}
if (entityManager == null)
{
throw new LoginException(LoginExceptionType.NoLoginManager, "No Login Manager");
}
var portalUserss = new EntityQuery<PORTAL_USERS>("PORTAL_USERS", entityManager);
var userInfoData = from credentials in portalUserss where (credentials.USER_NAME == credential.UserName && credentials.PASSWORD == credential.Password) select credentials;
if (userInfoData.Count() != 0)
identity = new UserIdentity(credential.UserName, "Custom", true);
else
identity = new UserIdentity(credential.UserName, "Custom", false);
var principal = new UserBase(identity);
return principal;
}
public void Logout(IPrincipal principal, EntityManager entityManager)
{
}
}
How do I get the customer number to LLBLGen Pro's implementation of the "OnModelCreating"?
The example I found for the "OnModelCreating" method is here - http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx
Thanks,
Stephane Touya
PS. A SMALL EXAMPLE WOULD BE GREAT!!!!