I have an author class like this
public class Author : IEquatable<Author>
{
public string Name { get; private set; }
public List<PublicationData> Publications { get; private set };
public Author(string name, List<PublicationData> publications)
{
Name = name;
Publications = publications;
}
public override string ToString()
{
string lines = Name + "\n";
foreach (PublicationData publication in Publications)
lines += publication.ToString() + "\n";
return lines;
}
public bool Equals(Author other)
{
return Name.Equals(other.Name);
}
public override int GetHashCode()
{
return Name.GetHashCode();
}
}
And I have publication class like this
public class PublicationData : IEquatable<PublicationData>
{
public string Code { get; set; }
public int Amount { get; set; }
public int Subscription_Length { get; set; }
public PublicationData(string name, int amount, int subscription_Length)
{
Code = name;
Amount = amount;
Subscription_Length = subscription_Length;
}
public override string ToString()
{
return String.Format($"{Code}, {Amount}, {Subscription_Length}");
}
public bool Equals(PublicationData other)
{
return Code.Equals(other.Code);
}
public override int GetHashCode()
{
return Code.GetHashCode();
}
}
Then I have a list of authors that look like this:
AuthorA
- PublicationA
AuthorB
- PublicationB
AuthorB
- PublicationC
I want to get something like this as a new object:
AuthorA
- PublicationA
AuthorB
- PublicationB
- PublicationC
I assume the code should look something like this:
var filtered = authors.Select(nn => new Author
(
nn.Name,
// merge publication lists
)).Distinct()
.ToList();
I just have no idea how do I do this. Can anyone suggest something?
It seems that you are looking for GroupBy method:
authors
.GroupBy(a => a.Name)
.Select(g => new Author(
g.Key,
g.SelectMany(ga => ga.Publications).ToList()))
You can also achieve it via the following code.
var query = from author in authors
group author by author.AuthorName;
foreach (var group in query)
{
Console.WriteLine(group.Key);
// Nested foreach is required to access group items.
foreach (var g in group)
{
Console.WriteLine($"\t{g.Publication}");
}
}
Here is a document Group query results you can refer to.
Related
I have a dictionary where values are stored in the following format -
userID, empDetails
For example,
1234, 'empName,jobDesc,CardNumber,Type'
I have to compare this information with another set of information such that -
If entered userId is present in the above dictionary, then remove this record from the dictionary.
If entered CardNumber is present (here userId is not known) in the above dictionary, then remove this record from the dictionary.
The first condition is simple and can be done by
dictionary.Remove(key)
But I am confused as to how would I implement the second condition. I want something like
if(CardNumber.PresentinAboveDictionary)
then
Remove that record
I know we can compare a partial string in a key like this, but I want to remove the record.
Check if any part of a hashtable value contains certain string c#
Assuming the employment details in your dictionary are a string in the specified format you would need to:
Search the values within the dictionary
Parse/Split the values to get the card numbers
Check the card numbers to see if they match the card number you are checking
Return the key value pair when a match occurs
Remove the entry for the key in the returned key value pair
Example code for the solution:
var dictionary = new Dictionary<int, string>() { { 1, "empName,jobDesc,124124134,Type" } };
var cardNumber = 124124134;
var entry = dictionary.FirstOrDefault(x => DoEmploymentDetailsContainCardNumber(x.Value, cardNumber));
if (!entry.Equals(default(KeyValuePair<int, string>)))
{
dictionary.Remove(entry.Key);
}
Method that checks if card number is present in employment details:
private static bool DoEmploymentDetailsContainCardNumber(string empDetails, int cardNumber)
{
var splitEmpDetails = empDetails.Split(',');
var empDetailsCardNumber = splitEmpDetails[2];
return empDetailsCardNumber == cardNumber.ToString();
}
Instead of Dictionary you can use a strongly typed List
Use the Linq builtin Remove method
Use Parallel.ForEach, iterate the list and remove the item (beware, takes more time)
pseudo code:
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Collections;
namespace ConsoleApp4
{
public class Employee
{
public Employee(int userID, string empDetails)
{
string[] props = empDetails.Split(new char[] { ',' }, StringSplitOptions.None);
this.userID = userID;
this.empName = props[0];
this.jobDesc = props[1];
this.CardNumber = props[2];
this.Type = props[3];
}
public int userID { get; set; }
public string empName { get; set; }
public string jobDesc { get; set; }
public string CardNumber { get; set; }
public string Type { get; set; }
}
public class MyCustomList : List<Employee>
{
public void Add(int userID, string empDetails)
{
this.Add(new Employee(userID, empDetails));
}
public bool Remove(string CardNumber)
{
bool found = false ;
Parallel.ForEach(this,
(i, state) =>
{
if (i.CardNumber == CardNumber)
{
this.Remove(i);
state.Break();
}
});
return found;
}
public bool RemoveV2(string CardNumber)
{
bool found = false;
if (this.Any(x => x.CardNumber == CardNumber))
{
this.Remove(this.Where(x => x.CardNumber == CardNumber).First());
found = true;
}
return found;
}
}
class Program
{
static void Main(string[] args)
{
var dict = new MyCustomList();//userID, empDetails list
dict.Add(12341, "empName1,jobDesc,CardNumber1,Type");
dict.Add(12342, "empName2,jobDesc,CardNumber2,Type");
dict.Add(12343, "empName3,jobDesc,CardNumber3,Type");
dict.Add(12344, "empName4,jobDesc,CardNumber4,Type");
dict.Add(12345, "empName5,jobDesc,CardNumber5,Type");
dict.Add(12346, "empName6,jobDesc,CardNumber6,Type");
dict.Add(12347, "empName7,jobDesc,CardNumber7,Type");
dict.Add(12348, "empName8,jobDesc,CardNumber8,Type");
//remove CardNumber5
dict.Remove("CardNumber5");
Console.Write(dict);
}
}
}
you can follow the simple approach to remove the key by using a loop here.
Here I am assuming that there is no key with a value of -1 in the dictionary.
int keyToRemove = -1;
foreach (var entry in dictionary)
{
if (entry.Value.Contains(CardNumber))
{
keyToRemove = entry.Key;
break;
}
}
if (keyToRemove != -1)
{
dictionary.Remove(keyToRemove);
}
This is possibly overkill and is not optimised for reading the full dataset repeatedly but it is considerably faster than the accepted solution. I put together a test of the solution below which did the following:
Generated 1,000,000 data rows with unique IDs and card numbers (the solution would also work if the card numbers were not unique)
Randomly removed 100,000 data items by ID and 100,000 data items by card number
Generated a list of the remaining data items
The process took around 75 seconds.
I then tried to repeat steps 1) and 2) using the accepted answer - after around 10 minutes it's about 7% of the way through removing data items. Therefore I think the solution below is around 2 orders of magnitude faster for this type of operation.
There are probably better doubley linked list implementations out there but I am not too familiar with any of them.
namespace Question
{
public class EmployeeCollection
{
private readonly Dictionary<int, ListNode<EmployeeDetails>> _idDictionary = new();
private readonly Dictionary<string, Dictionary<int, EmployeeDetails>> _cardNumberDictionary = new();
private readonly LinkedList<EmployeeDetails> _list = new();
public void AddEmployee(EmployeeDetails details)
{
var node = new ListNode<EmployeeDetails>(details);
_list.AddToStart(node);
_idDictionary.Add(details.Id, node);
if(!_cardNumberDictionary.ContainsKey(details.CardNumber))
{
_cardNumberDictionary.Add(details.CardNumber, new Dictionary<int, EmployeeDetails>());
}
_cardNumberDictionary[details.CardNumber].Add(details.Id, details);
}
public void RemoveById(int id)
{
if (_idDictionary.TryGetValue(id, out var node))
{
_idDictionary.Remove(id);
_list.Remove(node);
var list = _cardNumberDictionary[node.Value.CardNumber];
list.Remove(id);
if(list.Count == 0)
{
_cardNumberDictionary.Remove(node.Value.CardNumber);
}
}
}
public void RemoveByCardNumber(string cardNumber)
{
if (_cardNumberDictionary.TryGetValue(cardNumber, out var employees))
{
_cardNumberDictionary.Remove(cardNumber);
foreach (var employee in employees)
{
if (_idDictionary.TryGetValue(employee.Key, out var node))
{
_list.Remove(node);
}
}
}
}
public IEnumerable<EmployeeDetails> Employees => _list.GetAllValues();
public EmployeeDetails? GetById(int id)
{
if(_idDictionary.ContainsKey(id))
{
return _idDictionary[id].Value;
}
return null;
}
}
public class EmployeeDetails
{
public int Id { get; init; }
public string Name { get; init; }
public string JobDescription { get; init; }
public string CardNumber { get; init; }
public string Type { get; init; }
public static EmployeeDetails FromData(int id, string details)
{
var parts = details.Split(',');
return new EmployeeDetails
{
Id = id,
Name = parts[0],
JobDescription = parts[1],
CardNumber = parts[2],
Type = parts[3],
};
}
}
public class LinkedList<T>
{
public int Count { get; private set; }
private ListNode<T>? Start { get; set; }
private ListNode<T>? End { get; set; }
public bool IsEmpty => Count == 0;
public void AddToStart(ListNode<T> node)
{
ArgumentNullException.ThrowIfNull(nameof(node));
node.Next = null;
node.Previous = null;
if (IsEmpty)
{
Start = End = node;
}
else
{
Start!.Previous = node;
node.Next = Start;
Start = node;
}
Count++;
}
public void Remove(ListNode<T> node)
{
if (node != Start)
{
node.Previous!.Next = node.Next;
}
else
{
Start = node.Next;
}
if (node != End)
{
node.Next!.Previous = node.Previous;
}
else
{
End = node.Previous;
}
Count--;
}
public IEnumerable<T> GetAllValues()
{
var counter = Start;
while (counter != null)
{
yield return counter.Value;
counter = counter.Next;
}
}
}
public class ListNode<T>
{
public T Value { get; }
public ListNode<T>? Previous { get; set; }
public ListNode<T>? Next { get; set; }
public ListNode(T value)
{
Value = value;
}
}
}
you can do something like this.
var recordsToRemove = dictionary.Where(x => x.Value.Contains("what you are looking for"))
.ToList();
if (recordsToRemove.Any())
{
foreach (var record in recordsToRemove)
{
dictionary.Remove(record.Key);
}
}
i have table looks like below
ID | Reason | PrID
-----------------
1 abc null
2 dhe null
3 aerc 1
4 dwes 2
5 adfje 1
i have class
public class Reason
{
public int Id { get; set; }
public string Reson{ get; set; }
public List<SecondryReason> SecReason{ get; set; }
public int? PrimaryId { get; set; }
}
public class SecondryReason
{
public int Id { get; set; }
public string Reason { get; set; }
public int PrimaryReasonId { get; set; }
}
I want this to be displayed in hierarchy level
if the prid is Null need to treat this as the parent remaining all child
i am trying Linq and unable to achieve this
Suggest me how to do this in an easy way in linq
So: You have a list/enumerable of type , whereof the SecReason List property is null. Then, using linq you want a list, were the only the "root" reasons remain, but the Sub-reasons got put in the lists, but as type SecondaryReason?
If so, I found this way to do it (linq and foreach):
static IEnumerable<Reason> GetReasonsGrouped(List<Reason> reasons)
{
var result = reasons.Where(x => x.PrimaryId == null);
foreach (var item in result)
{
item.SecReason = reasons.Where(x => x.PrimaryId == item.Id)
.Select(x => new SecondryReason()
{ Id = x.Id,
ReasonName = x.ReasonName,
PrimaryReasonId = item.Id
})
.ToList();
}
return result;
}
Or just linq, but harder to read:
var result = reasons.Where(x => x.PrimaryId == null)
.Select(x =>
{
x.SecReason = reasons.Where(r => x.PrimaryId == x.Id)
.Select(r => new SecondryReason()
{
Id = r.Id,
ReasonName = x.ReasonName,
PrimaryReasonId = x.Id
})
.ToList();
return x;
});
Not sure if linq will be the best solution, here is my proposed changes and method to get an Hierarchy type:
public class Reason
{
public int Id { get; set; }
public string Reson { get; set; }
public List<Reason> SecReason { get; set; }
public int? PrimaryId { get; set; }
//Adds child to this reason object or any of its children/grandchildren/... identified by primaryId
public bool addChild(int primaryId, Reason newChildNode)
{
if (Id.Equals(primaryId))
{
addChild(newChildNode);
return true;
}
else
{
if (SecReason != null)
{
foreach (Reason child in SecReason)
{
if (child.addChild(primaryId, newChildNode))
return true;
}
}
}
return false;
}
public void addChild(Reason child)
{
if (SecReason == null) SecReason = new List<Reason>();
SecReason.Add(child);
}
}
private List<Reason> GetReasonsHierarchy(List<Reason> reasons)
{
List<Reason> reasonsHierarchy = new List<Reason>();
foreach (Reason r in reasons)
{
bool parentFound = false;
if (r.PrimaryId != null)
{
foreach (Reason parent in reasonsHierarchy)
{
parentFound = parent.addChild(r.PrimaryId.Value, r);
if (parentFound) break;
}
}
if (!parentFound) reasonsHierarchy.Add(r);
}
return reasonsHierarchy;
}
What is coming in to the webAPI is this JSON string and becomes deserilized in to this:
List<AddAssignMealView> mealtraiDeserializeObjects = JsonConvert.DeserializeObject<List<AddAssignMealView>>(mealTrainee);
mealtraiDeserializeObjects contains five index's one for each day of the week. Inside that specific index is a class that looks like what is below:
public class AddAssignMealView
{
public int TraineeID { get; set; }
public string DayOfTheWeek { get; set; }
public List<string> MealTypes { get; set; }
public List<int> MealID { get; set; }
public List<string> MealName { get; set; }
}
What I am trying to do is, be able to create a list of MealTrainee(Entity Framework):
public partial class MealTrainee
{
public int MealTraineeID { get; set; } //Ignore this one due to it being a post
public int MealID { get; set; }
public int TraineeID { get; set; }
public string DayOfTheWeek { get; set; }
public string MealType { get; set; }
public string MealName { get; set; }
public virtual Meal Meal { get; set; }
}
So I can be able to use addrange and add the list to the database. I understand how to use zip and combined two list types together if it is a single element. This is different due to it being a list of five elements and each of those five elements containing three lists. If someone could point me in the right direction, that would be helpful.
You can Zip 2 times to combine values from 3 lists into series of tuples. You can use SelectMany to flatten results. For example:
var result = mealtraiDeserializeObjects.SelectMany(c =>
c.MealID.Zip(c.MealName, (id,name) => new {id, name})
.Zip(c.MealTypes, (prev, type) => new {prev.id, prev.name, type})
.Select(r => new MealTrainee
{
TraineeID = c.TraineeID,
DayOfTheWeek = c.DayOfTheWeek,
MealID = r.id,
MealName = r.name,
MealType = r.type,
}));
This is the solution I found. I took it day by day in the sense that the first iteration would be Monday and then the count of meals(Ex:Meal for breakfast, Meal for Lunch) and put them in a count which would be "mealweek". Then I took mealweek and created a new mealtrainee for each count. Then after I made the meal out of the mealtrainee I put it in db.MealTrainees.AddRange and posted all the records.
[ResponseType(typeof(MealTrainee))]
public IHttpActionResult PostMealTrainee([FromBody] string mealTrainee)
{
List<MealTrainee> meals = new List<MealTrainee>();
using (DbContextTransaction dbContextTransaction = db.Database.BeginTransaction())
{
try
{
List<AddAssignMealView> mealtraiDeserializeObjects = JsonConvert.DeserializeObject<List<AddAssignMealView>>(mealTrainee);
foreach (var mealtraiDeserializeObject in mealtraiDeserializeObjects)
{
var mealWeek = mealtraiDeserializeObject.MealID.Select((m, i) => new
{
mealtraiDeserializeObject.TraineeID,
mealtraiDeserializeObject.DayOfTheWeek,
MealID = m,
MealTypes = mealtraiDeserializeObject.MealName[i],
MealName = mealtraiDeserializeObject.MealTypes[i]
}).ToList();
var meal = mealWeek.Select(x => new MealTrainee()
{
DayOfTheWeek = x.DayOfTheWeek,
MealID = x.MealID,
MealName = x.MealName,
MealType = x.MealTypes,
TraineeID = x.TraineeID
}).ToList();
db.MealTrainees.AddRange(meal);
}
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
db.SaveChanges();
dbContextTransaction.Commit();
return Ok(meals);
}
catch (Exception e)
{
dbContextTransaction.Rollback();
Logger.Log(e);
return BadRequest();
}
}
}
I have a collection of strings:
"Alberton;Johannesburg"
"Allendale;Phoenix"
"Brackenhurst;Alberton"
"Cape Town;"
"Durban;"
"Johannesburg;"
"Mayville;Durban"
"Phoenix;Durban"
"Sandton;Johannesburg"
that I want to structure into a hierarchical structure in the fastest possible manner, like:
Johannesburg
Alberton
Brackenhurst
Sandton
Cape Town
Durban
Phoenix
Allandale
Mayville
Currently I have nested for loops and checks, but was hoping I could achieve this with a single LAMBDA query?
The above mentioned strings are in a List.
I prepared lambda-like solution, but you should really think if it's more readable/efficient then your current one:
Helper Extension Method:
public static class ChildrenGroupExtensions
{
public static List<CityInfo> GetChildren(this IEnumerable<IGrouping<string, City>> source, string parentName)
{
var cities = source.SingleOrDefault(g => g.Key == parentName);
if (cities == null)
return new List<CityInfo>();
return cities.Select(c => new CityInfo { Name = c.Name, Children = source.GetChildren(c.Name) }).ToList();
}
}
Helper Classes:
public class City
{
public string Name { get; set; }
public string Parent { get; set; }
}
public class CityInfo
{
public string Name { get; set; }
public List<CityInfo> Children { get; set; }
}
Usage:
var groups = (from i in items
let s = i.Split(new[] { ';' })
select new City { Name = s[0], Parent = s[1] }).GroupBy(e => e.Parent);
var root = groups.GetChildren(string.Empty);
Where items is your List<string>
You can look the results with simple helper method like that one:
private static void PrintTree(List<CityInfo> source, int level)
{
if (source != null)
{
source.ForEach(c =>
{
Enumerable.Range(1, level).ToList().ForEach(i => Console.Write("\t"));
Console.WriteLine(c.Name);
PrintTree(c.Children, level + 1);
});
}
}
And the results are:
Cape Town
Durban
Mayville
Phoenix
Allendale
Johannesburg
Alberton
Brackenhurst
Sandton
You haven't specified any specific data structure so I just used a class called Area with a list of children of itself. Also, it's in 2 lines of linq. There is also no check to see if an area is a child of 2 separate parents as the code is. Here's the code for the test I used(Relevant lines in-between the equals comments):
[TestFixture]
public class CitiesTest
{
[Test]
public void Test()
{
var strings = new List<string>
{
"Alberton;Johannesburg",
"Allendale;Phoenix",
"Brackenhurst;Alberton",
"Cape Town;",
"Durban;",
"Johannesburg;",
"Mayville;Durban",
"Phoenix;Durban",
"Sandton;Johannesburg"
};
//===================================================
var allAreas = strings.SelectMany(x=>x.Split(';')).Where(x=>!string.IsNullOrWhiteSpace(x)).Distinct().ToDictionary(x=>x, x=>new Area{Name = x});
strings.ForEach(area =>
{
var areas = area.Split(';');
if (string.IsNullOrWhiteSpace(areas[1]))
return;
var childArea = allAreas[areas[0]];
if (!allAreas[areas[1]].Children.Contains(childArea))
allAreas[areas[1]].Children.Add(childArea);
childArea.IsParent = false;
});
var result = allAreas.Select(x=>x.Value).Where(x => x.IsParent);
//===================================================
}
public class Area
{
public string Name;
public bool IsParent;
public List<Area> Children { get; set; }
public Area()
{
Children = new List<Area>();
IsParent = true;
}
}
}
I just cannot get this to work, would appreciate if someone can help.
So I get back an XML result from a database which looks like:
<matches>
<issuer client_name="MTR" score="6" match_list="MTR CORPORATION LIMITED"/>
<issuer client_name="PEOPLE''S REPUBLIC OF CHINA" score="4"
match_list="DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA;GOVERNMENT OF THE
HONG KONG SPECIAL ADMINISTRATIVE REGION OF THE PEOPLE'S REPUBLIC OF
CHINA;MONGOLIAN PEOPLE'S REPUBLIC;PEOPLE'S DEMOCRATIC REPUBLIC OF
ALGERIA;PEOPLE'S REPUBLIC OF CHINA"/>
</matches>
From this XML I need to populate an object after doing some logic like matching the client_name I am getting back in the XML result to the one I have sent to database to get matches.
XDocument.Load(new StringReader(
row.GetString(row.GetOrdinal("xml_ret"))))))
.Single().Descendants("matches")
.Select(x =>
new Pool() {
Constituents = (IEnumerable<Constituent>)
//(... cannot work this how can IsReference populate)
//ClientName = x.Attribute("client_name").Value,
//Score = x.Attribute("score").Value,
//MatchList = x.Attribute("match_list").Value,
});
In a non-LINQ manner I can populate the object something like this:
foreach (Constituent constituent in pool.Constituents)
{
if (!string.IsNullOrEmpty(constituent.Name)
&& string.IsNullOrEmpty(constituent.Curve))
{
i++;
ConstituentMatch match = new ConstituentMatch();
ConstituentMatch.Group group =new ConstituentMatch.Group("High");
//High Match group
ICollection<string> curves = new List<string>();
curves.Add("EUR" + i);
curves.Add("USD" + i);
ICollection<string> names = new List<string>();
ConstituentMatch.Group.Entry entry =
new ConstituentMatch.Group.Entry(constituent.Name + " Ltd.",
curves);
group.Add(entry);
entry =
new ConstituentMatch.Group.Entry(constituent.Name + " Inc.",
curves);
group.Add(entry);
match.AddGroup(group);
}
}
But how can I do this using LINQ, as I am sure you can do it, I just cannot work it out.
The constituent class looks like:
public sealed class Constituent
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
public ConstituentMatch Match {get;set;}
public Constituent(string name)
{
this.name = name;
}
public Constituent() : this(string.Empty) { }
}
And constituent match class looks like this:
public sealed class ConstituentMatch
{
private readonly Dictionary<string, Group> matches = new Dictionary<string, Group>();
public IEnumerable<string> GroupNames
{
get { return matches.Keys; }
}
public Group this[string name]
{
get { return matches[name]; }
}
public IEnumerable<Group> Groups
{
get { return matches.Values; }
}
public void AddGroup(Group group)
{
matches[group.Name] = group;
}
/// <summary>
/// Match group e.g. Poor, High, All, Begins With
/// </summary>
public sealed class Group
{
private readonly string name;
private readonly ICollection<Entry> matches = new List<Entry>();
public string Name
{
get { return name; }
}
public Group(string name)
{
this.name = name;
}
public void Add(Entry entry)
{
matches.Add(entry);
}
public override bool Equals(object obj)
{
bool result = false;
if (obj is Group)
{
Group other = obj as Group;
result = name == other.name;
}
return result;
}
public override int GetHashCode()
{
return name.GetHashCode();
}
public sealed class Entry
{
private string legalName;
private IEnumerable<string> curves;
private double notional = double.NaN;
private char seniriority = 'N';
public string LegalName
{
get { return legalName; }
}
public IEnumerable<string> Curves
{
get { return curves; }
}
public Entry(string legalName, IEnumerable<string> curves)
: this(legalName, curves, double.NaN, 'N') { }
public Entry(string legalName,
IEnumerable<string> curves,
double notional,
char seniriority)
{
this.legalName = legalName;
this.curves = curves;
this.notional = notional;
this.seniriority = seniriority;
}
}
}
}
Some thing similar to this should work
var haystack = new Pool().Constituents;
var indexedhaystack = haystack.Select((item, index)=> new {
item, index
});
var pool = new Pool()
{
Constituents = from l in indexedhaystack
select new Constituent()
{
//your stuff here
}
};
... extended ...
var constituents = new Pool().Constituents.Select((c, i) =>
new
{
Constituent = c,
Index = i
});
var items = from c in constituents
where !string.IsNullOrEmpty(c.Constituent.Name)
&& string.IsNullOrEmpty(c.Constituent.Curve)
let curves = new[]{
"EUR" + c.Index.ToString(),
"USD" + c.Index.ToString()
}
let match = new ConstituentMatch(){
new Group("High") {
new Entry(
c.Constituent.Name + " Ltd.",
curves),
new Entry(
c.Constituent.Name + " Inc.",
curves)
}
}
select new
{
Name = c.Constituent.Name,
Curves = curves,
Match = match
};
...
public class Constituent
{
public string Name { get; set; }
public string Curve { get; set; }
}
public class Pool
{
public List<Constituent> Constituents { get; set; }
}
public class Entry
{
public Entry(string entry, IEnumerable<string> curves)
{
}
}
public class Group : List<Entry>
{
public Group(string group) { }
}
public class ConstituentMatch : List<Group>
{
}
Language INtegrated Query is, as its name says, a technology for querying objects and data, not for modifying them.