예제 #1
0
            public void ThePropertiesShouldBeCopied()
            {
                dynamic person = new
                {
                    Name = "Chris",
                    Age  = 42,
                };

                TestStaticClass result = DynamicToStatic.ToStatic <TestStaticClass>(person);

                result.ShouldHave().AllPropertiesBut(@class => @class.Birthday).EqualTo(person);
            }
예제 #2
0
            public void ItShouldThrowAnException()
            {
                dynamic person = new
                {
                    Name  = "Chris",
                    Age   = 42,
                    Phone = "5551212",
                };

                var result = Capture.Exception(() => DynamicToStatic.ToStatic <TestStaticClass>(person));

                result.Should().BeOfType <RuntimeBinderException>();
            }
예제 #3
0
        public IList <vEmployee> GetEmployeesByMetadataAndFilter(IList <string> metadataToShow, string filterString, IList <FilterArgument> filterArguments)
        {
            var query = DbSet.Select(string.Format("new ({0})", string.Join(",", metadataToShow.ToArray())));

            if (!string.IsNullOrEmpty(filterString))
            {
                query = query.Where(filterString, ProcessFilterArguments(filterArguments));
            }

            var lstEmployee = new List <vEmployee>();

            foreach (dynamic item in query)
            {
                lstEmployee.Add(DynamicToStatic.ToStatic <vEmployee>(item));
            }

            return(lstEmployee);
        }