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 Query
- 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?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- How to avoid loop by using LINQ for the following code?
- How can we express the following code using query expression?
- How to write this code using the Linq Extension Method-Syntax?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How do I do the following using Lambda or Linq statement?
- How to simplify the code Using LINQ
- How to execute the following SQL-Query using LINQ or HQL
- How do i do the following using LINQ feature of C#?
- How to add an AND/OR expression to the following dynamic linq expression
- Simplify the following code to a one-liner using Linq queries
- How to use dynamic linq when using inheritance (TPH) in the entities
- How to convert the following code to LINQ format?
- How to convert the following foreach loop to linq code format?
- How would I do the following logic using LINQ
- How do i group a list of dynamic objects using linq given that the property names are dynamic?
- how I can have the following value using Linq
- How does the following LINQ statement work?
- How can I filter a dictionary using LINQ and return it to a dictionary from the same type
- how to update the multiple rows at a time using linq to sql?
- How do I find the text within a div in the source of a web page using C#
- How do I count the number of child collection's items using LINQ Method Syntax?
- How to use GroupBy using Dynamic LINQ
- How to do a Sum using Dynamic LINQ
- Dynamic Expression using LINQ. How To Find the Kitchens?
- How to get all elements except the n'th element in a List using Linq
- How to find the first item according to a specific ordering using LINQ in O(n)?
- When using a LINQ Where clause on a Dictionary, how can I return a dictionary of the same type?
More Query from same tag
- using linq with Join and Max using DataTables
- Filter a List of Strings and select only one occurance of a string with multiple occurance
- How do I translate this specifik SQL statement to LINQ
- Convert to IEnumerable<DateTime> result of LINQ Query
- lambda expression function body to sql query
- Get the depth of an Item
- How can i create pagination properly with List<IGrouping<string,Product>>?
- OData V3 exclude property
- How many times will Linq to Objects iterate over a source?
- Insert XML into an XML element
- Entity Framework Select Statement with Logic
- Ravendb / F# / Linq
- LINQ query doesn't return the single value
- Searching for an item in a list that's nested inside another list based on a property value in C# using LINQ?
- LINQ GroupBy Month and Color Count
- Why do I have to copy "this" when using LINQ in a struct (and is it OK if I do)?
- C# Declare variable in lambda expression
- ASP Recomendation needed: (Linq or SqlDataSource?) + (Response.Write or UserControls or Repeater?
- Mutilevel include in C# Linq
- Delete outer xml node without deleting inner xml
- Using Linq to get maximum value of only duplicates
- Can I do a subquery in in SELECT of LINQ to Entities to fill List in model?
- LINQ dictionary to jagged array?
- Find inconsistent and consecutive objects from List in C#
- Enumerable.Any method is not supported
- How do I rewrite this line using method syntax?
- Asp.NET DataTable query using linq
- MVC 3 - The model item passed into the dictionary is of type 'System.Collections.Generic.List`1
- Programmatically Add Row to Linq-to-SQL Dataset
- Usage recursive hierarchy tree structure in Linq query with multible tables and return some Json Value