Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions samples/docker-compose/dotnet/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ private async Task<Tuple<ISpace, IIndex, IIndex>> Initialize()

public async Task<ViewResult> Index()
{
var allDogs = await _primaryIndex.Select<TarantoolTuple<long>, TarantoolTuple<long, string, long, MsgPackToken>>(TarantoolTuple.Create(-1L), new SelectOptions { Iterator = Iterator.All });
var seniorDogs = await _secondaryIndex.Select<TarantoolTuple<long>, TarantoolTuple<long, string, long, MsgPackToken>>(TarantoolTuple.Create(5L), new SelectOptions { Iterator = Iterator.Ge });
var juniorDogs = await _secondaryIndex.Select<TarantoolTuple<long>, TarantoolTuple<long, string, long, MsgPackToken>>(TarantoolTuple.Create(5L), new SelectOptions { Iterator = Iterator.Le });
var allDogs = await _primaryIndex.Select<TarantoolTuple<long>, Dog>(TarantoolTuple.Create(-1L), new SelectOptions { Iterator = Iterator.All });
var seniorDogs = await _secondaryIndex.Select<TarantoolTuple<long>, Dog>(TarantoolTuple.Create(5L), new SelectOptions { Iterator = Iterator.Ge });
var juniorDogs = await _secondaryIndex.Select<TarantoolTuple<long>, Dog>(TarantoolTuple.Create(5L), new SelectOptions { Iterator = Iterator.Le });

return View(new []
{
allDogs.Data.Select(x => new Dog(x)).ToArray(),
seniorDogs.Data.Select(x => new Dog(x)).ToArray(),
juniorDogs.Data.Select(x => new Dog(x)).ToArray()
allDogs.Data,
seniorDogs.Data,
juniorDogs.Data
});
}
}
Expand Down
29 changes: 19 additions & 10 deletions samples/docker-compose/dotnet/Models/Dog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@

namespace dotnet.Models
{
[MsgPackArray]
public class Dog
{
public Dog(TarantoolTuple<long, string, long, MsgPackToken> tuple)
{
Id = tuple.Item1;
Name = tuple.Item2;
Age = tuple.Item3;
var _ = TryParseString(tuple.Item4) || TryParseInt(tuple.Item4);
}
private MsgPackToken _addditionalDataRaw;

public long Id { get; }
[MsgPackArrayElement(0)]
public long Id { get; set; }

public string Name { get; }
[MsgPackArrayElement(1)]
public string Name { get; set; }

public long Age { get; }
[MsgPackArrayElement(2)]
public long Age { get; set; }

[MsgPackArrayElement(3)]
public MsgPackToken AddditionalDataRaw
{
get => _addditionalDataRaw;
set
{
_addditionalDataRaw = value;
var _ = TryParseString(value) || TryParseInt(value);
}
}

public string AdditionalData { get; private set; }

Expand Down
13 changes: 11 additions & 2 deletions samples/docker-compose/dotnet/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using dotnet.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using ProGaudi.MsgPack.Light;
using ProGaudi.Tarantool.Client;
using ProGaudi.Tarantool.Client.Model;

namespace dotnet
{
Expand All @@ -28,7 +30,14 @@ public void ConfigureServices(IServiceCollection services)
// Add framework services.
services.AddMvc();

var box = Box.Connect("operator:123123@tarantool1:3301").GetAwaiter().GetResult();
var msgPackContext = new MsgPackContext();
msgPackContext.GenerateAndRegisterArrayConverter<Dog>();

var clientOptions = new ClientOptions("operator:123123@tarantool1:3301", context: msgPackContext);

var box = new Box(clientOptions);
box.Connect().ConfigureAwait(false).GetAwaiter().GetResult();

services.AddSingleton(box);
}

Expand Down
3 changes: 2 additions & 1 deletion samples/docker-compose/dotnet/dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="progaudi.tarantool" Version="0.7.0" />
<PackageReference Include="msgpack.light" Version="1.3.0" />
<PackageReference Include="progaudi.tarantool" Version="0.8.0" />
</ItemGroup>
</Project>