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 Query
- 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
More Query from same tag
- C# Linq - Find Duplicate value in list and select it's id
- Linq "where" condition with nullable object property result in "invoke non static method requires a target"
- C# - Loading XML file in parts
- Populate a large list of objects with details from another list
- Linq InsertOnSubmit is throwing exception: Object reference not set to an instance of an object
- When an Expression<T> is compiled, is it implicitly cached?
- How to create the function using Expression linq
- How to flatten a GroupBy and select in linq
- Accessing a List multiple times in same code block - Any better approach?
- Multiple linq joins but different operators
- C# Linq with more than two nested levels
- How do I edit this LINQ query for nested classes using Entity Framework
- How do I write SELECT FROM myTable WHERE id = (SELECT) in Linq?
- Filtration strongly typed result
- Simple way of extracting the a unique item from a C# list<T> with the total amout of items of that type
- Is there a better way (fastest) to get the longest common folder path?
- Does LINQ to XML loads whole xml document during query?
- Problem with LINQ - necessary to add reference to unneeded library
- LINQ with Lambda expression - Join, Group By, Sum and Count
- Using Linq and C#, how would I categorize a list of list and getting empty categories?
- LambdaExpression gets incorrect DeclaringType for overriden property
- Nhibernate 3.0 IQueryOver group by and fetch one entire record in each group which satisfy the condition
- Add the XAttribute to XElement if attribute exists in the element
- display the first N words from database field in DataList
- Ho to Convert a Uint to Nullable Int in a EF Query
- windows phone 8 edit/update local database
- Better way to cater the stringlist
- LINQ: Inner join to the First row in a sub query?
- Can't find property or field on a dynamic object
- xml many to many join using linq