public void DetailInFunctionTest() { var dvd = new DetailVariableDef(); dvd.ConnectMasterPorp = "Берлога"; dvd.OwnerConnectProp = new[] { SQLWhereLanguageDef.StormMainObjectKey }; dvd.View = Information.GetView("МедведьE", typeof(Медведь)); dvd.Type = langdef.GetObjectType("Details"); var function = langdef.GetFunction(langdef.funcExist, dvd, langdef.GetFunction(langdef.funcEQ, new VariableDef(langdef.GuidType, "Наименование"), string.Empty)); var expectedPropertiesUsedInFunction = new List <string> { "Наименование" }; var propertiesUsedInFunction = new List <string>(); var detailList = new List <ViewPropertyAppender.DetailVariableDefContainer>(); ViewPropertyAppender.FindPropertiesUsedInFunction(function, propertiesUsedInFunction, detailList); Assert.Equal(0, propertiesUsedInFunction.Count); Assert.Equal(1, detailList.Count); var intersection = expectedPropertiesUsedInFunction.Intersect(detailList[0].DetailVariablesList).ToList(); Assert.Equal(expectedPropertiesUsedInFunction.Count, intersection.Count); }
public void NullFunctionTest() { var expectedPropertiesUsedInFunction = new List <string>(); var propertiesUsedInFunction = new List <string>(); ViewPropertyAppender.FindPropertiesUsedInFunction(null, expectedPropertiesUsedInFunction, new List <ViewPropertyAppender.DetailVariableDefContainer>()); var intersection = expectedPropertiesUsedInFunction.Intersect(propertiesUsedInFunction).ToList(); Assert.Equal(expectedPropertiesUsedInFunction.Count, intersection.Count); }
public void AddPropertyByLimitFunctionWithExpression() { var ds = (SQLDataService)DataServiceProvider.DataService; var function = langdef.GetFunction(langdef.funcEQ, new VariableDef(langdef.GuidType, "МедведьСтрокой"), "Бум"); var view = ViewPropertyAppender.GetViewWithPropertiesUsedInFunction(Медведь.Views.МедведьShort, function, ds); var expectedPropertiesUsedInFunction = new List <string> { "МедведьСтрокой", "ПорядковыйНомер", "Мама.ЦветГлаз" }; var propertiesUsedInFunction = view.Properties.Select(p => p.Name).ToList(); var intersection = expectedPropertiesUsedInFunction.Intersect(propertiesUsedInFunction).ToList(); Assert.Equal(expectedPropertiesUsedInFunction.Count, intersection.Count); }
/// <summary> /// Создаётся новое представление, в которое добавляются свойства используемые в LINQ-выражении. /// </summary> /// <param name="expr">LINQ-выражение</param> /// <param name="dataObjectType">Тип</param> /// <param name="view">Начальное представление</param> /// <param name="dataService">Сервис данных</param> /// <returns>Представление</returns> public static View GetViewWithPropertiesUsedInExpression(Expression expr, Type dataObjectType, View view, IDataService dataService) { var lcs = LinqToLcs.GetLcs(expr, dataObjectType); if (lcs.ColumnsSort != null) { foreach (var sortDef in lcs.ColumnsSort) { view.AddProperty(sortDef.Name, sortDef.Name, false, string.Empty); } } if (lcs.LimitFunction == null) { return(view); } return(ViewPropertyAppender.GetViewWithPropertiesUsedInFunction(view, lcs.LimitFunction, dataService)); }
public void SimpleDoubledPropertyTest() { var function = langdef.GetFunction( langdef.funcAND, langdef.GetFunction(langdef.funcEQ, langdef.GetFunction(langdef.funcYearPart, new VariableDef(langdef.DateTimeType, "ДатаВыдачи")), "2012"), langdef.GetFunction(langdef.funcEQ, langdef.GetFunction(langdef.funcMonthPart, new VariableDef(langdef.DateTimeType, "ДатаВыдачи")), "12")); var expectedPropertiesUsedInFunction = new List <string> { "ДатаВыдачи" }; var propertiesUsedInFunction = new List <string>(); ViewPropertyAppender.FindPropertiesUsedInFunction(function, propertiesUsedInFunction, new List <ViewPropertyAppender.DetailVariableDefContainer>()); var intersection = expectedPropertiesUsedInFunction.Intersect(propertiesUsedInFunction).ToList(); Assert.Equal(expectedPropertiesUsedInFunction.Count, intersection.Count); }
public void EnrichDetailViewTest() { var dvd = new DetailVariableDef(); dvd.ConnectMasterPorp = Information.ExtractPropertyPath <Выплаты>(x => x.Кредит1); dvd.OwnerConnectProp = new[] { SQLWhereLanguageDef.StormMainObjectKey }; dvd.View = new View { DefineClassType = typeof(Выплаты) }; dvd.Type = langdef.GetObjectType("Details"); var function = langdef.GetFunction( langdef.funcExist, dvd, langdef.GetFunction( langdef.funcAND, langdef.GetFunction(langdef.funcEQ, new VariableDef(langdef.DateTimeType, Information.ExtractPropertyPath <Выплаты>(x => x.ДатаВыплаты)), DateTime.Now), langdef.GetFunction(langdef.funcEQ, new VariableDef(langdef.NumericType, Information.ExtractPropertyPath <Выплаты>(x => x.СуммаВыплаты)), 123))); ViewPropertyAppender.EnrichDetailViewInLimitFunction(function, DataServiceProvider.DataService); Assert.Equal(2, dvd.View.Properties.Count()); Assert.Equal(Information.ExtractPropertyPath <Выплаты>(x => x.ДатаВыплаты), dvd.View.Properties[0].Name); Assert.Equal(Information.ExtractPropertyPath <Выплаты>(x => x.СуммаВыплаты), dvd.View.Properties[1].Name); }