Why does this LINQ not work? Im trying to get All Countries from a class (only countries [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I'm trying to get all Countries from my database for a combo box.
This is my code for it:
public IQueryable<Customer> GetAllCountries()
{
var query = from e in Entities
select e.Country;
return query;
}
It gives me an error at return query;
I only want the Countries for my combo box, even though there are cities and all sorts in the Customer class.

I managed to fix it by using IQueriable<string> instead of Customer!

Related

backend with .Net [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
here is the whole association model of my database
the problem is that I need to read the list of Equipment displayed at each Employee
*An employee has one or more Post
*A Post has one or more Equipment
I created the backend part with .NET
I tried to read the list of posts of an employee and then read the list of Equipment by the id of each post
/*********************************/
[HttpGet]
public async Task<IEnumerable<GetEquiPostDto>> GetEmpPostListAsync(string id)
{
var EmpPost=(await PostRepository.GetEmppPostAsync(id))
.Select(EmpPost=>EmpPost.GetEmpPostDto()).ToList();
for(int i=0;i<EmpPost.Count;i++)
{
var EquiPost=(await EquipRepository.GetEquippPostAsync(EmpPost[i].PostId))
.Select(EquiPost=>EquiPost.GetEquiPostDto());
}
return EquiPost;
}

C# Get Object Values [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to C#.
I have a method that returns an object with the List of objects inside.
0 {{DapperRow, RecordedFormID = 'id1'}} object {Dapper.SqlMapper.DapperRow}
1 {{DapperRow, RecordedFormID = 'id2'}} object {Dapper.SqlMapper.DapperRow}
How can I get those ids as strings?
Here is a screenshot
You can use System.Linq namespace and do this:
yourObject.Select(x => x.RecordedFormID);

C# how to get diagram name of element - Enterprise Architect [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I need to get diagram`s name of specific elements. Is it possible ?
I added elements note with specific stereotypu using profile to EA project. Then i want create a plugin where i find this notes and diagram names where they are located. (i want export notes and diagram names to excel)....PS: Sorry for my bad english
Issue a SQL like
Repository.SQLQuery("SELECT t_diagram.name FROM t_diagramobjects AS dobj INNER JOIN t_diagram ON dobj.diagram_id = t_diagram.diagram_id WHERE t_diagramobjects.Object_ID = <elementID>"
Just replace <elementID> with the element's elementID. You could alternatively retrieve the diagram GUID (t_diagram.ea_guid') and get the diagram details viaRepostory.GetDiagramByGUID`.

How to linq to split string (only if delimer exists) and create array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
public class itemObject { public string items; }
values - item = "name1,name2" or items = "item3"
Need linq to split by ',' if exists else one string array.
This doesnt require linq, its the default behaviour of String.Split
var array = items.Split(',');

Searching an object in a collection via lambda and does not return true even if it exist [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
https://www.youtube.com/watch?v=K1xrlc32Tmw&list=PLJUoF2h8Z-brW94dTZ-ZIOhjFq90_lt5K&index=9
4:25 adds a new object in the lineCollection if product does not exist in lineCollection, but at 24:25 it shows duplicating orders? Did i misunderstood how it works?
https://github.com/jedjad/GitHubVS2013
Because the products in duplicate values are not same objects. They may have same names, quantity etc, but initializing a class with same values does not mean that it is the same object as the one initialized before. They are like 2 different apples with same color and size.
If you say that 2 products are same whenever the names are same, then implement IEquatable<Product> in Product class.
public bool Equals(Product other)
{
return Name == other.Name;
}

Categories