public void PrepareSelectExpression() { var singleDataInfo = new StreamedSingleValueInfo(typeof(int), false); var selectProjection = Expression.Constant(0); var subStatement = new SqlStatement(singleDataInfo, selectProjection, new SqlTable[0], null, null, new Ordering[0], null, false, null, null); var expressionWithSubStatement = new SqlSubStatementExpression(subStatement); var result = _stage.PrepareSelectExpression(expressionWithSubStatement, _context); Assert.That(result, Is.SameAs(expressionWithSubStatement)); }
public void PrepareSelectExpression () { var singleDataInfo = new StreamedSingleValueInfo (typeof (int), false); var selectProjection = Expression.Constant (0); var subStatement = new SqlStatement (singleDataInfo, selectProjection, new SqlTable[0], null, null, new Ordering[0], null, false, null, null); var expressionWithSubStatement = new SqlSubStatementExpression (subStatement); var result = _stage.PrepareSelectExpression (expressionWithSubStatement, _context); Assert.That (result, Is.SameAs(expressionWithSubStatement)); }
public void RecalculateDataInfo_UnchangedProjectionType_SameDataInfo() { var statementBuilder = new SqlStatementBuilder(); var previousSelectProjection = Expression.Constant("test"); var originalDataInfo = new StreamedSingleValueInfo(typeof(string), false); statementBuilder.DataInfo = originalDataInfo; statementBuilder.SelectProjection = new SqlColumnDefinitionExpression(typeof(string), "c", "Length", false); statementBuilder.RecalculateDataInfo(previousSelectProjection); Assert.That(statementBuilder.DataInfo, Is.SameAs(originalDataInfo)); }
public void ExecuteQueryModel_WithValueType() { var queryModel = ExpressionHelper.CreateQueryModel_Int(); var executorMock = MockRepository.GenerateMock <IQueryExecutor> (); executorMock.Expect(mock => mock.ExecuteSingle <int> (queryModel, true)).Return(5); var streamedSingleValueInfo = new StreamedSingleValueInfo(typeof(int), true); var streamedData = streamedSingleValueInfo.ExecuteQueryModel(queryModel, executorMock); executorMock.VerifyAllExpectations(); Assert.That(streamedData, Is.InstanceOf(typeof(StreamedValue))); Assert.That(streamedData.DataInfo, Is.SameAs(streamedSingleValueInfo)); Assert.That(streamedData.Value, Is.EqualTo(5)); }
public void RecalculateDataInfo(Expression previousSelectProjection) { if (SelectProjection.Type != previousSelectProjection.Type) // TODO: Consider removing this check and the parameter { var sequenceInfo = DataInfo as StreamedSequenceInfo; if (sequenceInfo != null) { DataInfo = new StreamedSequenceInfo(typeof(IQueryable <>).MakeGenericType(SelectProjection.Type), SelectProjection); } var singleValueInfo = DataInfo as StreamedSingleValueInfo; if (singleValueInfo != null) { DataInfo = new StreamedSingleValueInfo(SelectProjection.Type, singleValueInfo.ReturnDefaultWhenEmpty); } // For scalar queries, the DataInfo never needs to be recalculated. } }
public void SetUp() { _streamedSingleValueInfoWithDefault = new StreamedSingleValueInfo(typeof(Cook), true); _streamedSingleValueInfoNoDefault = new StreamedSingleValueInfo(typeof(Cook), false); }
public void RecalculateDataInfo_UnchangedProjectionType_SameDataInfo () { var statementBuilder = new SqlStatementBuilder (); var previousSelectProjection = Expression.Constant ("test"); var originalDataInfo = new StreamedSingleValueInfo (typeof(string), false); statementBuilder.DataInfo = originalDataInfo; statementBuilder.SelectProjection = new SqlColumnDefinitionExpression (typeof (string), "c", "Length", false); statementBuilder.RecalculateDataInfo (previousSelectProjection); Assert.That (statementBuilder.DataInfo, Is.SameAs (originalDataInfo)); }
public void RecalculateDataInfo (Expression previousSelectProjection) { if (SelectProjection.Type != previousSelectProjection.Type) // TODO: Consider removing this check and the parameter { var sequenceInfo = DataInfo as StreamedSequenceInfo; if (sequenceInfo != null) DataInfo = new StreamedSequenceInfo (typeof (IQueryable<>).MakeGenericType (SelectProjection.Type), SelectProjection); var singleValueInfo = DataInfo as StreamedSingleValueInfo; if (singleValueInfo != null) DataInfo = new StreamedSingleValueInfo (SelectProjection.Type, singleValueInfo.ReturnDefaultWhenEmpty); // For scalar queries, the DataInfo never needs to be recalculated. } }
public void ExecuteQueryModel_WithValueType () { var queryModel = ExpressionHelper.CreateQueryModel_Int (); var executorMock = MockRepository.GenerateMock<IQueryExecutor> (); executorMock.Expect (mock => mock.ExecuteSingle<int> (queryModel, true)).Return (5); var streamedSingleValueInfo = new StreamedSingleValueInfo (typeof (int), true); var streamedData = streamedSingleValueInfo.ExecuteQueryModel (queryModel, executorMock); executorMock.VerifyAllExpectations (); Assert.That (streamedData, Is.InstanceOf (typeof (StreamedValue))); Assert.That (streamedData.DataInfo, Is.SameAs (streamedSingleValueInfo)); Assert.That (streamedData.Value, Is.EqualTo (5)); }
public void SetUp () { _streamedSingleValueInfoWithDefault = new StreamedSingleValueInfo (typeof (Cook), true); _streamedSingleValueInfoNoDefault = new StreamedSingleValueInfo (typeof (Cook), false); }