https://github.com/miiitch/wilinq
A Linq provider over the VSTS Workitem api
https://github.com/miiitch/wilinq
dotnet linq rest-api tfs tfs-api vsts workitem
Last synced: 4 months ago
JSON representation
A Linq provider over the VSTS Workitem api
- Host: GitHub
- URL: https://github.com/miiitch/wilinq
- Owner: miiitch
- License: apache-2.0
- Created: 2015-08-12T15:23:37.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-10T16:40:34.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T11:02:28.625Z (over 1 year ago)
- Topics: dotnet, linq, rest-api, tfs, tfs-api, vsts, workitem
- Language: C#
- Homepage:
- Size: 12.7 MB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Linq provider for VSTS/TFS workitem queries
## Prerequisites
This provider uses the VSTS Rest API to query the workitem repository. The provider uses the standard nuget [client package](https://www.nuget.org/packages/Microsoft.TeamFoundationServer.Client)
## How it queries works
The provider works like extensions to the `WorkItemTrackingHttpClient` class:
### Queries on the WorkItem class
The provider support queries on the standard WorkItem class. Use the Field extention method to target specific workitem fields:
```csharp
var assignedToMe = from workitem in Client.All()
where workitem.Field("System.AssignedTo") == QueryConstant.Me
select workitem;
```
### Queries on Generic workitem
The provider contains a specific GenericWorkItem class. This class has the following purposes:
* base class for types workitems
* typed fields
* to hide the complexity of the update api
```csharp
var projectWiQuery = from bug in Client.SetOf()
where bug.CreatedBy == bug.ChangedBy
select bug;
```
### Queries on Typed workitems
You can inherits from the Generic WorkItem class and create typed version of workitems. When used, the provider automaticaly add a filter on the workitem type
Bug definition:
```csharp
[WorkItemType("Bug")]
public class Bug : GenericWorkItem
{
[Field("Microsoft.VSTS.Common.Priority")]
public virtual int? Priority
{
get => GetStructField("Microsoft.VSTS.Common.Priority");
set => SetStructField("Microsoft.VSTS.Common.Priority", value);
}
}
```
Query on bugs:
```csharp
var projectWiQuery = from bug in Client.SetOf()
where bug.CreatedBy == bug.ChangedBy && bug.Priority == 2
select bug;
```
### Queries on Process Template
You can register a set of typed workitems and let the provider instanciate the right version:
```csharp
public class ScrumTemplate : ProcessTemplate
{
public ScrumTemplate()
{
AddWorkItemType();
AddWorkItemType();
AddWorkItemType();
AddWorkItemType();
AddWorkItemType();
// ...
}
}
```
```csharp
var q = from workitem in Client.FromTemplate()
select workitem;
```
### Syn or Async queries
As any linq provider, sync queries are supported. You can also use a specific extension method to retrieve the data as an async query:
```csharp
var projectWiQuery = from bug in Client.SetOf(Project)
where bug.IsUnderIteration(iteration)
select bug;
var result = await projectWiQuery.ToListAsync();
```
## Create and save typed workitems
Typed workitems can be created and saved by using the New<> and Save<> methods:
```csharp
var bug = Project.New();
bug.Title = "New bug created";
await Client.Save(bug);
bug.Title = "Title Changed";
bug.Priority = 2;
await Client.Save(bug);
```