0

I see in this question people saying using greater than or less than on a Guid field is a bad idea. I have a specific reason for wanting to do this though. I have a lot of data I want to pull from a web service, data that is essentially grouped by a Guid for several records. I'd like to be able to Get one Guid worth of data, then make another call for the next, etc. Seeing as how I can order by a Guid, I don't see why I shouldn't be able to do a greater than. I'd like to be able to Order on the Guid, grab the first, then pass that Guid back into my web service, do the same order by, and then select the first record that's 'greater than' the last guid.

I don't want to use a sequence number because it's possible someone would insert a record while I'm in the middle of doing this, and I don't want to get a duplicate record. My alternative is to use another one of my fields to do a greater than on.. but I know for a fact that the Guid field will not be changing. Is there a way to do this? Or am I just going about the problem wrong.

This is my code

NextAgent = SHEntity.qry_UnreleasedSearches.Where(w => w.AgentGUID > PreviousAgentGuid).OrderBy(o => o.AgentGUID)

Which just gives me a delegate does not take one argument error.

Community
  • 1
  • 1
cost
  • 4,420
  • 8
  • 48
  • 80
  • What happens when someone inserts some data that that gets a GUID that is the first record 'greater than' the last GUID? – Zache Jan 15 '14 at 09:35
  • @Zache Then it gets included in my batch pull. If they insert a Guid 'less than' it, it gets ignored until the next pull. – cost Jan 15 '14 at 10:01
  • @cost Zache is correct GUID are not guaranteed to be sequential. Eventually a GUID of lesser value then the one you have will be added. Can you elaborate on how having a sequence number could cause duplication? – Taras Alenin Jan 15 '14 at 10:26
  • @BigT Possibly I didn't explain what I meant very well. I don't care if they're sequential, the only thing I want to guarantee is that I don't get the same record twice. When I said sequence, I meant querying it using a LINQ Skip. Essentially I want every record from a query, but I want them one at a time, each from a separate web service call. If a new GUID is added that's after my current one, that's fine, I get it. But if one is added before my current one, I don't want it to shift everything forward by one and I get the same record twice. Does that make sense? – cost Jan 15 '14 at 10:32
  • @cost I think you should be fine. In the end a GUID is just a large random number. Considering (if understand you correctly) you are processing same data over and over (with each "pull" as you mentioned above). Eventually you will pick and process all the data. Note however that you records are not going to be processed in the order they are created/added. – Taras Alenin Jan 16 '14 at 01:09

0 Answers0