1

I am creating an application extension for a software package call ESRI ArcGIS Desktop in .NET 4 and WPF. It will rely tabular data but I would like the storage options for this data be as flexible as possible. So the user can pull in things like Access mdbs, csv, xml, SQL Server, etc.

I would like to use LINQ but being new to it I am having trouble figuring out if it suitable. From what I read an EDMX is out which is fine but was not sure if LINQ will really work well without one. I was reading about the IQueryable which seems like it might work. But before I spend too long spinning my wheels I wanted to see if I am barking up the wrong tree.

Should I look further into something like IQueryable or am I making it overly complicated and can use something like IEnumrable, List, or Dictionaries, etc and LINQ should be fine with those? Or will this work at all?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ernie S
  • 13,902
  • 4
  • 52
  • 79
  • I think that depends a lot on what you need. Do you need to translate your queries in SQL (when the source is SQL database)? – svick Feb 01 '13 at 18:12
  • Your question specifically targets ArcGIS, but a similar discussion can be found in: http://stackoverflow.com/q/7411504/861716. Especially [this answer](http://stackoverflow.com/a/7414597/861716) spots the problem: `IQueryable` can behave quite differently with different implementations. It can be done, but you must be aware of possible differences (to name a few: case sensitivity, dealing with null values, support for specific data types, which linq methods will and won't be accepted by a query provider). A hell of a job, frankly. Try to limit the number of supported platforms first. – Gert Arnold Feb 01 '13 at 19:14
  • Thanks guys. I mention ArcGIS althought I dont think it will have much bearing on that part of the code. What I mean is the part of the code that will be hitting the data sources will do so directly and not through any part of ArcGIS (Layers, Tables, etc.). So its kind of like working with ADO - it is mostly outside the host apps object model. When the data is actually extracted out of the source is when the Arc object model will come into play. – Ernie S Feb 01 '13 at 20:54

1 Answers1

0

You can use LINQ to Objects with any IEnumerable<T>. If you're working against ArcObjects, it's unlikely that any data source will be directly usable, however, as their "collections" aren't .NET collections.

You can easily wrap them in your own IEnumerable<T> wrapper, and then use LINQ to Objects against them.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • Thanks, that helps alot actually. The LINQ To Objects is the part I really needed. So it seems that I can get the data out of the source (via file IO or data connection depending on the source) and then transfer it to collections and hit THOSE with LINQ? Looks like I have alot more reading to do. – Ernie S Feb 01 '13 at 20:54
  • @Ernie Yes - LINQ to Objects works against any in-memory collection, as well as "virtual" collections (things that are streamed, etc), as long as they implement `IEnumerable` – Reed Copsey Feb 01 '13 at 20:58