//---------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Collections.Generic;
using System.Data.Common.CommandTrees;
using System.Data.Common.Utils;
namespace System.Data.Common.CommandTrees.ExpressionBuilder
{
///
/// The Row class is intended to provide a constructor-like means of calling .
///
public sealed class Row
{
private readonly System.Collections.ObjectModel.ReadOnlyCollection> arguments;
///
/// Constructs a new Row with the specified first column value and optional successive column values
///
/// A key-value pair that provides the first column in the new row instance (required)
/// Key-value pairs that provide any subsequent columns in the new row instance (optional)
public Row(KeyValuePair columnValue, params KeyValuePair[] columnValues)
{
this.arguments = new System.Collections.ObjectModel.ReadOnlyCollection>(Helpers.Prepend(columnValues, columnValue));
}
///
/// Creates a new that constructs a new row based on the columns
/// contained in this Row instance.
///
/// A new DbNewInstanceExpression that constructs a row with the same column names and DbExpression values as this Row instance
///
public DbNewInstanceExpression ToExpression()
{
return DbExpressionBuilder.NewRow(this.arguments);
}
///
/// Converts the given Row instance into an instance of
///
///
/// A DbExpression based on the Row instance
/// is null.
///
public static implicit operator DbExpression(Row row)
{
EntityUtil.CheckArgumentNull(row, "row");
return row.ToExpression();
}
}
}