Wednesday, November 2, 2011

get around the "you do not have permissions" thing bug in TFS

You may see this when attempting an update in Team Foundation Server: ..."could not update the work item because it was already updated by another user, it does not exist, or you do not have permission to update it."

One way around this problem:


...is to open a task/bug list (in Team Explorer), and single-click on a task/bug to open it below the list in the same tab in lieu of opening it in its own tab by way of double-clicking.

Tuesday, November 1, 2011

Sticking With LinqSpecs!

We have a new consensus on LinqSpec in that it is understood that is not a bad approach to building queries. Specifications can break NHibernate in scenarios such as:

x = > myGuidCollection.Contains(x.Id)

 
 

...but instead of these being viewed as pitfalls it is more appropriate to understand that the burden is still upon us to craft queries appropriately.

Firebug Tabs

The Console tab allows one to see what errors one's JavaScript is causing. The Script tab allows one to set breakpoints in JavaScript and to step through code.

.Contains may sabotage LinqSpec working in tandem with NHibernate

Using .Contains in a LinqSpec Specification can create a query that NHibernate will not be able to support. The trouble comes when the .Contain trails an empty collection. I learned the hard way that this...

public static Specification<ProgramOffering> ProgramAndProgramPlanCriteria(

      IList<Guid> programIds, IList<Guid> programPlanIds)

{

   var programPlanSpec = new AdHocSpecification<ProgramOffering>(

         po => programPlanIds.Contains(po.ProgramPlan.Id) ||

         programIds.Contains(po.ProgramPlan.Program.Id));

   return programPlanSpec;

}

 
 

...had to be refactored to this...

public static Specification<ProgramOffering> ProgramAndProgramPlanCriteria(

      IList<Guid> programIds, IList<Guid> programPlanIds)

{

   List<Guid> programAndProgramPlanIds = new List<Guid>(){};

   programAndProgramPlanIds.AddRange(programIds);

   programAndProgramPlanIds.AddRange(programPlanIds);

   var programPlanSpec = new AdHocSpecification<ProgramOffering>(

         po => programAndProgramPlanIds.Contains(po.ProgramPlan.Id) ||

         programAndProgramPlanIds.Contains(po.ProgramPlan.Program.Id));

   return programPlanSpec;

}

 
 

...to account for situations in which one of the two collections handed in was flawed as hinted at here.

My theories were wrong.

My theories here are wrong.

Rafael recommends perhaps using NHibernate Criteria in lieu of LinqSpecs

This looks like perhaps a better way to approach the same concern that LinqSpec manages when using NHibernate. I dunno. :P

a letter a wrote (on LinqSpec)

Hi Jorge,
I can think of a refinement I need to make when I am in this morning. I believe the reason three tests I had around PM/PC/AM for ProgramOfferings started to fail is that I am using one LinqSpec for matching both a ProgramOffering on both ProgramPlan Id and Program Id. There is a spec with a firstcollection.Contains(ProgramPlan) || secondcollection.Comtains(Program) shape and if the first collection is empty I think it sabotages the second.

If it seems inappropriate for me to shove these two concerns into one spec, I would agree that it is. An NHibernate error is thrown when I try to use two separate specs for each concern in tandem as a query NHibernate cannot manage is crafted. I am thus trying to work around the problem.

I think I can solve the problem by making a union of firstcollection and secondcollection above and using the union collection in place of the two collections in the LinqSpec specification.

Let's talk today if it's OK, albeit I'm not sure what to do about our LinqSpec w/ NHibernate challenges. :(

Waiting to carpool with Bhavani now. Should be in soon.

Thanks,
Tom


Sent from my iPhone