score:0
I tried this:
using System;
using System.Linq;
using System.Linq.Dynamic;
using System.Collections.Generic;
namespace ConsoleApplication1
{
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Tags { get; set; }
}
class Program
{
static void Main( string[] args )
{
var Customers = new List<Customer>(){ new Customer(){ FirstName = "test", LastName = "case"}};
var query2 = Customers.Select(
cust => new Customer
{
FirstName = cust.FirstName,
LastName = cust.LastName,
Tags="sampleTag,Tag"
}
).ToList<Customer>();
var query1 = Customers.AsQueryable().Select( "new (FirstName, LastName, \"sampleTag,Tag\" AS Tags)" );
foreach(dynamic cust in query1)
{
Console.WriteLine(cust.Tags);
}
Console.ReadLine();
}
}
}
Source: stackoverflow.com
Related Articles
- How to do the following in Dynamic Linq using System.Linq.Dynamic namespace
- How can I write the following code more elegantly using LINQ query syntax?
- Simplify the following code to a one-liner using Linq queries
- Convert string[] to int[] in one line of code using LINQ
- Empty namespace using Linq Xml
- How to use GroupBy using Dynamic LINQ
- Query data using "Contains" keyword in Dynamic Linq in C#
- Accessing System Databases/Tables using LINQ to SQL?
- How to do a Sum using Dynamic LINQ
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- Dynamic query using LINQ to SQL
- Dynamic linq query expression tree for sql IN clause using Entity framework
- Using DateTime in Dynamic LINQ to Entities
- What's elegant way to rewrite following LINQ statement using extension methods?
- Building a dynamic where clause for dynamic keywords or using IQueryable C# Linq
- Left outer join using LINQ -- understanding the code
- How to reuse a linq expression for 'Where' when using multiple source tables
- Avoiding code repetition when using LINQ
- Using LINQ to delete an element from a ObservableCollection Source
- Using LINQ Dynamic Query Library with Dictionary<string, object> and .AsQueryable()
- LINQ Source Code Available
- How do I define a SELECT TOP using LINQ with a dynamic query?
- How to realize tsql "IN" equivalent using dynamic Linq
- how to create a pivot table with dynamic column using linq tree expression
- Dynamic LINQ to DataTable: why using hardcode string "it" as DataRow
- Querying xml child elements with prefixed namespace using LINQ to XML
- How can I code an outer join using LINQ and EF6?
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- How to add namespace to xml using linq xml
- how do i build dynamic linq queries at runtime using strings?
- System.String ToString() error on a database call using c#
- Correct use of null-conditional operator in LINQ while reading XML
- Count Dates which a specific Customer does not have a Shop in it
- The fastest way to find dictionary keys that are not exist in another list
- Concatenate Property of a object in Collection.
- To obtain a result list from many to many relationship in Entity Framework
- SQL data projection with nested query in ef-core
- Sequence contains no elements with LINQ FirstOrDefault
- Efficient linq query for changing rank order of entities
- Sort a Dictionary using LINQ
- Filter linq list on property value
- How to run Linq with order by and group by
- Unusual error when returning list of results from API
- Delete query not working
- LINQ Iterator Exception Handling
- LINQ to find count of all Datapoints in ASP.NET Chart
- Retrieving the row index of row pulled from datatable useing Linq
- C# Not Rounding Double
- Linq query and returning DateTime field in a short date format
- Group By and Sum In LINQ query with Join