Replacements for some BLToolkit classes or methods missing in LinqToDB

20 views Asked by At

I'm migrating from BLToolkit to LinqToDB. And I couldn't find replacements for some classes or methods missing in LinqToDB.

  1. IDataContext.Delete() and IDataContext.InsertOrReplace() cannot accept IEnumerable<T> anymore. Is iterating over entities collection and using db.InsertOrReplace(inputEntities[i]) the only option? Isn't that a performance hit?
  2. In our class derived from MappingSchema in some cases instead of our custom conversions we used base.ConvertChangeType(). Now it's missing - what is supposed to be used instead?
  3. We used dbManager.SetCommand(command, params).Prepare() - Prepare is missing now. How to prepare command for execution?
  4. IObjectFactory.CreateInstance has no InitContext context argument anymore. How to obtain context.MappingSchema, context.DataSource and context.SourceObject now?
  5. In BLToolkit we used SqlQueryInfo to change parameter names in query like that:
public static void SetCommand<TEntity>([NotNull] this DbManager dbManager, TEntity entity, string actionName)
{
    var queryInfo = new SqlQuery<TEntity>(dbManager).GetSqlQueryInfo(dbManager, typeof(TEntity), actionName);
    var queryText = queryInfo.QueryText;
    var parameters = queryInfo.GetParameters(dbManager, entity);
    for (var i = 0; i < parameters.Length; i++)
    {
        var parameterName = parameters[i].ParameterName;
        //Parameters and Where-clause for primary key
        if (parameterName.EndsWith("_P") || parameterName.EndsWith("_W"))
        {
            var newName = parameterName.Substring(0, parameterName.Length - 2);
            queryText = queryText.Replace(parameterName, newName);
            parameters[i].ParameterName = newName;
        }
    }
    dbManager.SetCommand(queryText, parameters);
}

SqlQuery and SqlQueryInfo are missing - what to use instead?

0

There are 0 answers