Generate Data Access Components

Sep 28, 2013 at 11:18 PM
HI,

when i try make a new project and i´m going to create the data access components for proyect Data, i have the option to use Enterprise Library DAAB 6.0 how can i change that and can i use the Entity Framework 5.0?


Thanks
Coordinator
Oct 13, 2013 at 11:56 PM
Hi,

LASG only supports Enterprise Library for data access code generation and do not support Entity Framework (because code generation is already provided by Entity Framework itself).

Hugs,
Serena
Oct 14, 2013 at 5:58 PM
Hi Serena,

thanks for your help

I have a question , when I download the LeaveSample solution , the proyect Data has a LeaveDAC class
and it has the method

BA_DATABASE_TYPE result = default(BA_DATABASE_TYPE);
  // Data access component declarations.
  BA_DATABASE_TYPEDAC bA_DATABASE_TYPEDAC = new BA_DATABASE_TYPEDAC();

  // Step 1 - Calling Create on BA_DATABASE_TYPEDAC.
  result = bA_DATABASE_TYPEDAC.Create(bA_DATABASE_TYPE);

  return result;
When i create a class similar , it generate :


const string SQL_STATEMENT =
    "INSERT INTO dbo.BA_DATABASE_TYPE (DESCRIPTION) " +
    "VALUES(@DESCRIPTION); SELECT SCOPE_IDENTITY();";

  // Connect to database.
  Database db = DatabaseFactory.CreateDatabase(CONNECTION_NAME);
  using (DbCommand cmd = db.GetSqlStringCommand(SQL_STATEMENT))
  {
    // Set parameter values.
    db.AddInParameter(cmd, "@DESCRIPTION", DbType.AnsiString, bA_DATABASE_TYPE.DESCRIPTION);

    // Get the primary key value.
    bA_DATABASE_TYPE.DATABASE_TYPE_ID = Convert.ToDecimal(db.ExecuteScalar(cmd));
  }

  return bA_DATABASE_TYPE;
I want to know, as they did that?


Thanks
Coordinator
Oct 27, 2013 at 2:08 PM
Hi,

I am not quite sure about your question. If you want to know whether LASG can generate those code that you posted, the answer is Yes.

However, if you are looking at using Entity Framework, then you will need to hand-code the DAC yourself. You can download the EF version of the LeaveSample to get an idea of how the code looks like :)

Hugs,
Serena