I need to group the following list by the department value but am having trouble with the LINQ syntax. Here's my list of objects:
var people = new List<Person>
{
new Person { name = "John", department = new List<fields> {new fields { name = "department", value = "IT"}}},
new Person { name = "Sally", department = new List<fields> {new fields { name = "department", value = "IT"}}},
new Person { name = "Bob", department = new List<fields> {new fields { name = "department", value = "Finance"}}},
new Person { name = "Wanda", department = new List<fields> {new fields { name = "department", value = "Finance"}}},
};
I've toyed around with grouping. This is as far as I've got:
var query = from p in people
from field in p.department
where field.name == "department"
group p by field.value into departments
select new
{
Department = departments.Key,
Name = departments
};
So can iterate over the groups, but not sure how to list the Person names -
foreach (var department in query)
{
Console.WriteLine("Department: {0}", department.Department);
foreach (var foo in department.Department)
{
// ??
}
}
Any ideas on what to do better or how to list the names of the relevant departments?
I have the following class:
public abstract class MyClass<T extends Object> {
protected T createNewFromData(Reader reader){
GSON.fromJSON(reader,T.class); // T.class isn't allowed :(
}
}
How do I pass a Class<T instance into there? Is there some wierd and wacky work around?
Is there a way to get a Class<T reference other than from a pre-instantiated Object of type T? It won't let me do this either:
T t = new T();
Class<T> klass = t.class;
ANSWER BELOW
Thanks to the accepted answer, here is the solution:
Type type = new TypeToken<T>(){}.getType();
return gson.fromJson(reader, type);
I got 1 parent property class and 3 child property class. Here is my example
Parent class
public class blcSalesParam
{
public string selectFrom
{
get;
set;
}
public string pageAction
{
get;
set;
}
}
Child class
public class blcDeliveryOrder
{
public int? DeliveryID
{
get;
set;
}
public string DeliveryCode
{
get;
set;
}
I'm making a C++ wrapper for a piece of C code that returns a large array, and so I've tried to return the data in a vector<unsigned char>.
Now the problem is, the data is on the order of megabytes, and vector unnecessarily initializes its storage, which essentially turns out to cut down my speed by half.
How do I prevent this?
Or, if it's not possible -- is there some other STL container that would avoid such needless work? Or must I end up making my own container?
(Pre-C++11)
Note:
I'm passing the vector as my output buffer. I'm not copying the data from elsewhere.
I have created an Organization which has four user groups. I want to restrict the user group to view the file uploaded by the other user group.
i.e
Organization 1
User Group 1
A
B
User Group 2
C
D
User Group 3
E
F
User Group 4
G
H
I am using CustomLanding hook to land on the organization page.
From above, If A uploads a document, it can be viewed only by B in user group 1.
Like the same I want to restrict the viewable condition to other groups also.
Please guide me to achieve this.
Regards,
Dinesh.
I have explained some of the state mechanisms that we have in our disposal for preserving state in ASP.Net applications in various posts in this blog. You can have a look at this post , this post , this post and this one . I have not presented yet an example in using the Application class/object for preserving state within our application. Application state is available globally in an application.The way we access Application State is through the HttpApplication object's Application property. Let...(read more)
Entity Framework’s new 4.0 designer does its best to generate correct plural and singular forms of object names. This magic is done through the PluralizationService Class found in the System.Data.Entity.Design.PluralizationServices namespace and in the System.Data.Entity.Design.dll assembly. [Before you ask… Yes, I’ll post my example page, the service, and the project source code as soon as my ISP makes ASP.NET 4 RTM available. Stay tuned.] Anyone who speaks English is brutally aware of the ridiculous...(read more)
Windows Vista and 7 provide the ability to restart crashed or hung applications and recover your work. By building on the strength of the Document-View Architecture, Microsoft Foundation Class (MFC) 10 allows new and existing applications to easily take advantage of these Windows features.
Managing configuration settings is an important part of successful applications. It should be easy to ensure that you can easily access and modify configuration values within your applications. If it's not - well things don't get parameterized as much as they should. In this post I discuss a custom Application Configuration class that makes it super easy to create reusable configuration objects in your applications using a code-first approach and the ability to persist configuration information into various types of configuration stores.
Kevin has posted about the Parallel class and how to use it to easily do multiple operations at once without radically changing the structure of your code. Very neat stuff. Jonathan Cogley is the CEO of Thycotic Software, an agile software services and product development company based in Washington DC. Secret Server is our flagship enterprise password vault.
I have class design for storing patient information
could you please review the design and let me know anything wrong or not corrent
I have designed three interfaces
IPatient
IPatientHistory
IPrescription
IPatient
Id
Firstname
LastName
DOB
BloogGroup
Mobile
List<IPatientHistory>
-----------------------
GetPatientById()
GetPatientHistory()
IPatientHistory
HistoryId
PatientId
DateOfVisit
cause
List<IPrescription>
-----------------------
GetPrescription()
IPrescription
PrescriptionId
PatientHistoryId
MedicineName
totalQty
MorningQty
NoonQty
NightQTy
Much of the routine administration of Reporting Services (SSRS), such as the routine deployment of RDL reports, can be automated by using the Reporting Service 2005 class library and web services. To make things easier, Microsoft supply the RS utility to run Visual Basic code as a script. It is an intriguing system, with a lot of potential, as Greg Larsen explains.
We have acquired two additional tickets to attend the SQL Server Master Class with Paul Randal and Kimberly Tripp For a chance to win these coveted tickets In the subject line type MasterClass and email [email protected] before 9pm on Sunday night The winners will be announced Monday Morning Don’t worry if you have already purchased a ticket, should you be win, your ticket cost will be reimbursed
Hear Nadeem Syed, Oracle Group Vice President, Advanced Planning Products discusst Oracle's recently announced best-in-class Supply Chain Planning solutions: Advanced Planning Command Center, Demand Signal Repository, Spare Parts Planning and Manufacturing Operations Center. Gain an understanding of the capabilities of these ground-breaking planning solutions and what types of enterprises can benefit from them.
Hear Nadeem Syed, Oracle Group Vice President, Advanced Planning Products discusst Oracle's recently announced best-in-class Supply Chain Planning solutions: Advanced Planning Command Center, Demand Signal Repository, Spare Parts Planning and Manufacturing Operations Center. Gain an understanding of the capabilities of these ground-breaking planning solutions and what types of enterprises can benefit from them.
Before entering in to Mutex, I need to explain it's functional difference with Monitor class. This difference is still seeing as a hot discussion in side various communities. The difference is the scope between two types. Scope of Mutex is wider than Monitor.
There are a great number of services in the online world. Most of these services include the best of Multiple Class C IP Addresses which are available with the webmaster at the best possible prices.
There are a great number of SEO Hosting Services in the world today that are formulated with the intention of being able to create and develop winning strategies for their websites to rank well on the top search engines of the world. The need for SEO Hosting has come at a time when webmasters are seeking ways in which they can assign multiple C Class IP Addresses to all of their domains and mange as well as create some of the best services that are able to know where webmasters can control all their domains from one single cPanel.
Lorsque l'on développe pour plusieurs plateformes (.Net, Silverlight, XNA, Windows Phone 7), il se pose souvent la question de comment partager le code ?
La Portable Class Library permet de répondre efficacement à cette problématique puisqu'elle permet à un projet d'être multiplateforme. Nous allons voir comment l'utiliser dans un cas de figure où il faut partager du code entre un client Silverlight et le serveur.
Retrouver l'article ici...
There are numerous SEO colleges that offer fun, easy and affordable online SEO short courses as well as marketing subjects. There are no special requirements needed and these courses assume zero knowledge and do not require any previous HTML or programming background. In addition to an SEO class you will be provided with links for online tutorials which will supply you with valuable information.
Learning how SEO Hosting can help a webmaster can be a daunting task. This article explains the basics of SEO Hosting by stressing on the importance of Multiple C Class IPs.
Another very important thing that you have to remember is that your site should be able to feature in the very first page of a search engine or else it is of no use. This is how you can use C Class IP address Ranges.