score:3
Accepted answer
How about:
var query = from property in _target.GetType().GetProperties()
let attributes = Attribute.GetCustomAttributes(property, true)
where attributes.Any()
let val = _propertyValueAccessor.GetValue(_target, property)
from attribute in attributes
select new PropertyContext
{
PropertyValue = val,
Annotation = attribute,
SourceType = _target,
};
Source: stackoverflow.com
Related Articles
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- query properties of an object with linq
- Linq custom query with object properties
- Iterate through properties and values of an object returned via a linq query on a domain model
- Problem with LINQ to Entities query using Sum on child object property
- C# Create object with dynamic properties : LINQ select List<object> values by property names array
- Linq with where clause in many-to-many EF Code First object
- Combine object properties into a list with LINQ
- LINQ query on object with unknown class
- Query for existence of an object with LINQ (to Entities)
- How to get the value of class properties with Linq query and IEnumerable
- How can I speed up this linq query on a List<> with search criteria on 3 attributes in the list object
- Linq query performance with new object in `Where`
- Linq sub query when using a repository pattern with EF code first
- Linq to sql as object data source - designer problem with partial classes
- LINQ Query for An object with 2 collections
- LINQ query to filter list by object property with multiple checks
- how to query a sub object of an object with linq
- Linq query with select needed to get specific properties from a list
- LINQ - Grouping a list by multiple properties and returning an object with an array member
- convert linq to object query to sql query (no linq to sql code or datacontext)
- Verify type, properties of Linq object with T anonymous parameter in function
- Building which properties to select with LINQ To Object
- Linq query to include items with on a join object
- Setting all properties of dynamic object in anonymous type in linq query
- How to query a stored procedure object with Linq
- Is factory-based object construction and property assignment possible with LINQ query syntax?
- Avoiding repeating code with Linq query + optional params
- LINQ query finding object with closest data variable to query input variable
- Flatten LINQ Collection
- List Iteration to Create Custom List in C#(Linq)
- Unable to cast object of type 'System.Byte' to type 'System.String'
- Making an outer join on two anonymous type lists using LINQ in Entity Framework
- List Of List group Result
- Regrouping Multiple rows into one
- Can we convert this For-loop into LINQ?
- vb.net Linq statement to find duplicates using fuzzy searching
- How to a compose a Linq Expression to call OrderBy on a set of entities?
- C# LINQ Z-Score query output to a Dictionary<string, SortedList<DateTime, double>>
- Linq To Entities - Filter on list
- NHibernate 3 LINQ inner join issue with three jumps: NotSupportedException
- 'List' does not contain a definition for 'Where'
- C# Linq - Issue with joining tables with multiple fields - Error CS1941
- LINQ match two lists within a select statement
- LINQ to XML how compare children with repeater items
- Filtering a nested list and out put as tree
- LINQ Queries work in LINQ Pad not in VS
- Why is var Int32 not List<Int32> in this example
- Filter DataSet by email address with LINQ query not working