LLBLGenProDynamicDataSource Validate Entity

Posts   
 
    
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 18-Sep-2009 15:42:39   

Hi,

I have LLBLGenProDynamicDataSource datasource control and related DetailsView. I want to apply some kind of validation logic which requires an Entity.

Is there any way how to get the Entity from datasource/detailsview in Page.Validate() method? I want to use CustomValidator to apply my validation logic and validate entity before EntityInserting (or PerformWork) event is called.

Thanks!

Daniel, using LLBL Gen Pro 2.6.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Sep-2009 07:41:16   

Could you elaborate on how your validation scenario is setup? Are you using LLBLGenPro built-in validation? or just validating via the MetadataType and data annotations?

David Elizondo | LLBLGen Support Team
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 22-Sep-2009 19:36:36   

I have three projects in the solution

DynamicDataWeb BLL LLBL

all the bussiness logic is in BLL project, LLBL doesn't have reference to BLL.

Now it's


protected void DetailsDataSource_EntityUpdating(object sender, CancelableDataSourceActionEventArgs e)
    {
      string error;
      if (!Bll.ValidationLogic.Validate(e.InvolvedEntity, out error))
      {
        Utils.RegisterJScriptAlert(error);
        e.Cancel = true;
      }
    }

What I want:


  protected void EntityValidator_Validate(object sender, ServerValidateEventArgs args)
  {
    string error;
    args.IsValid = Bll.ValidationLogic.Validate(DetailsDataSource.Entity, out error);
   (sender as CustomValidator).ErrorMessage = error;
  }


  protected void btnSave_Click(object sender, EventArgs e)
  {
    DetailsView1.UpdateItem(true); //will not update item if Page.IsValid == false
  }

where DetailsDataSource.Entity in EntityValidator is what I want to get. But there could be many scenarios when an Enity created from DataSource and user inputs in DetailsView would be cool.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Sep-2009 07:12:02   

I don't think it can be made like that.

Why not just use the LLBLGen built-in validating feature. You can validate fields, validate before save and of course you can validate in you BL (f.i. validate inside some BL.SaveMyStuf(...) ). You always can livepersistence=false and do whatever you want on PerformWork event handler.

David Elizondo | LLBLGen Support Team