Search for inconsistency in a C#list

Asked

Viewed 60 times

1

Good afternoon.

I have a list of the Project class The Project class has the properties:

    public string ID { get; set; }
    public string Nome_Usuario { get; set; }
    public string Nome_Projeto { get; set; }

In this list I can have the same ID, User name and Project name repeatedly.

Example

inserir a descrição da imagem aqui

The name João with ID = 1 appears several times in my class, with it I can use the value of the PROJECT field to update other records that is not the case.

Now I can’t use the Marcos registry because it participates in two different projects and cannot be used in my upgrade.

  • What is the doubt?

  • How can I have the control to update or not the value of the PROJECT field following the above mentioned rules.

  • Several times would be greater than or equal to 2 equal projects for each ID?

  • yes. I can have the same record several times with different projects

  • I still don’t understand what you want to do. Can you explain what you want to do and what your question is otherwise? Maybe the problem is my lack of interpretation, I don’t know...

2 answers

3


You can try using the . All() extension method, but you will have to pass the project as parameter. If you inform the LG Project in João’s list, the method will return you true and when you do the same query with the LG Project in Marcos' list, it will be false because not all are LG. Anything puts the code that can help.

0

I believe that you should better relate your information. It seems to me that this is a case where there would be a class "Collaborator.Cs":

public string id { get; set; }
public string name { get; set; }

a class "Project.Cs":

public string id { get; set; }
public string name{ get; set; }

and a class that related both "Jobs.Cs":

public string id { get; set; }
public string idColaborator { get; set; }
public string idProject { get; set; }

So you would only need to reference the unique id of the Jobs class to do your update.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.