public void ThePropertiesShouldBeCopied() { dynamic person = new { Name = "Chris", Age = 42, }; TestStaticClass result = DynamicToStatic.ToStatic <TestStaticClass>(person); result.ShouldHave().AllPropertiesBut(@class => @class.Birthday).EqualTo(person); }
public void ItShouldThrowAnException() { dynamic person = new { Name = "Chris", Age = 42, Phone = "5551212", }; var result = Capture.Exception(() => DynamicToStatic.ToStatic <TestStaticClass>(person)); result.Should().BeOfType <RuntimeBinderException>(); }
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); }