score:1
Accepted answer
If you are creating the objects at that time, using object initalizers is probably the cleanest coded solution.
var model = new myMvcModel()
{
FirstName = input.FirstName,
LastName = input.LastName,
City = input.City
}
Otherwise using reflection or AutoMapper as Ek0nomik suggest are your only solutions that I could suggest.
Like Ek0nomik I prefer to do it manually rather than AutoMapper. Even created a VS macro to inspect both objects and output some scaffolding.
Source: stackoverflow.com
Related Query
- Can mapping the results of a linq query being mapped to a class be simplified?
- Mapping Linq Query results to a DTO class
- How can I write the following code more elegantly using LINQ query syntax?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How can I get the type of the results of a LINQ query before executing it?
- Can I Use The Same Linq Code to Query for Different Conditions?
- Can I assign the result of a Linq query to the source variable of the same query?
- How can I convert Linq results to DTO class object without iteration
- The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation EF Core 3.1
- How can I trace the query produced by the documentdb Linq provider?
- Call class method inside the Linq Query
- The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation
- LINQ : The query results cannot be enumerated more than once
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- How can I view the Entity Framework LINQ query plan cache?
- Can you map the results of a manual SQL query to objects in Entity Framework?
- filter a linq query based on the results of another query's results
- The LINQ expression could not be translated. Eiither rewrite the query in a form that can be translated
- How do I get results from a Linq query in the order of IDs that I provide?
- Determine the source DataContext for a Linq to Sql query
- What is the proper way to use linq Group operators to Flatten Query Results
- LINQ query returns old results when source list is re-initialized
- need linq query to return only the last 100 results
- 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
- Can you set a property in a linq query before selecting the item?
- How can I code a Linq query to do an upward Include?
- Inheriting a Linq to SQL class and cast the result of a linq query
- Linq - How to aggregate the results of another query
- LINQ translation doesn't give the same results as my SQL query
More Query from same tag
- .net + SQL + Timeout issue
- C# Linq question
- Is there a not in sub-query for Linq to Enties as in this T-SQL
- Get values from stored procedure to class in c# using linqToSql
- Generic Tree Structure - How to populate an org chart
- How to add a Case statement to my LINQ Query
- Something confusing about IQueryable<T>.GetEnumerator
- LINQ Grouping by ParentId
- Read CSV data in batches and Process it
- Linq Left Outer Join Two Tables on Two Fields
- How to find the least amount of common sets
- What is the best way to generate an id for new Xelement in Linq to XML?
- How to write the result of IGrouping?
- Use LINQ to find complex combinations of items in two lists
- Group by in LINQ on a property in an array
- .NET / C# - Proper Method to Use Here - LINQ
- Linq vs MS Enterprise Library DAAB
- Linq query foreach element in array
- Converting Anonymous Type To Nominal Type
- Getting current, previous and next schedule in Linq
- Creating expressions for a different object
- C# How to use .OrderBy with multiple columns and decode column number to column name?
- LINQ in Entity Framework append onto DATETIME WHERE clause
- mvc Groupby and Orderby nested
- LINQ query help please, for each works?
- Linq - Orderby by ID Value
- How to filter only a element from a sequence (IEnumerable) in LINQ
- Linq, combining multiple records into comma separated string, grouped by distinct value
- LINQ with group by for nested list
- get value Session