Example #1
0
 public CrmDataAdapter(CrmDbCommand selectCommand)
     : base()
 {
     this.SelectCommand = selectCommand;
 }
Example #2
0
 public CrmDataAdapter(CrmDbCommand selectCommand)
     : base()
 {
     this.SelectCommand = selectCommand;
 }
        /// <summary>
        /// Create a SampleCommand object, given the provider manifest and command tree
        /// </summary>
        private DbCommand CreateCommand(DbProviderManifest manifest, DbCommandTree commandTree)
        {
            if (manifest == null)
                throw new ArgumentNullException("manifest");

            if (commandTree == null)
                throw new ArgumentNullException("commandTree");

            CrmEfProviderManifest sampleManifest = (manifest as CrmEfProviderManifest);
            if (sampleManifest == null)
            {
                throw new ArgumentException("The provider manifest given is not of type 'CrmEfProviderManifest'.");
            }

            //StoreVersion version = sampleManifest.Version;

            CrmDbCommand command = new CrmDbCommand();

            // List<DbParameter> parameters;
            //CommandType commandType;

            throw new NotImplementedException();

            //command.CommandText = SqlGenerator.GenerateSql(commandTree, out parameters, out commandType);
            //command.CommandType = commandType;

            //if (command.CommandType == CommandType.Text)
            //{
            //    //command.CommandText += Environment.NewLine + Environment.NewLine + "-- provider: " + this.GetType().Assembly.FullName;
            //}

            //// Get the function (if any) implemented by the command tree since this influences our interpretation of parameters
            //EdmFunction function = null;
            //if (commandTree is DbFunctionCommandTree)
            //{
            //    function = ((DbFunctionCommandTree)commandTree).EdmFunction;
            //}

            //// Now make sure we populate the command's parameters from the CQT's parameters:
            //foreach (KeyValuePair<string, TypeUsage> queryParameter in commandTree.Parameters)
            //{
            //    CrmParameter parameter;

            //    // Use the corresponding function parameter TypeUsage where available (currently, the SSDL facets and
            //    // type trump user-defined facets and type in the EntityCommand).
            //    FunctionParameter functionParameter;
            //    if (null != function && function.Parameters.TryGetValue(queryParameter.Key, false, out functionParameter))
            //    {
            //        parameter = CreateParameter(functionParameter.Name, functionParameter.TypeUsage, functionParameter.Mode, DBNull.Value);
            //    }
            //    else
            //    {
            //        parameter = CreateParameter(queryParameter.Key, queryParameter.Value, ParameterMode.In, DBNull.Value);
            //    }

            //    command.Parameters.Add(parameter);
            //}

            //// Now add parameters added as part of SQL gen (note: this feature is only safe for DML SQL gen which
            //// does not support user parameters, where there is no risk of name collision)
            //if (null != parameters && 0 < parameters.Count)
            //{
            //    if (!(commandTree is DbInsertCommandTree) &&
            //        !(commandTree is DbUpdateCommandTree) &&
            //        !(commandTree is DbDeleteCommandTree))
            //    {
            //        throw new InvalidOperationException("SqlGenParametersNotPermitted");
            //    }

            //    foreach (DbParameter parameter in parameters)
            //    {
            //        command.Parameters.Add(parameter);
            //    }
            //}

            //return command;
        }