Skip to content

Commit 3b12d9d

Browse files
documentation updates, bug fix (#13)
Co-authored-by: jeffrey-elliott <[email protected]> Co-authored-by: Steve Hewitt <[email protected]>
1 parent bce7d37 commit 3b12d9d

File tree

5 files changed

+158
-3
lines changed

5 files changed

+158
-3
lines changed

images/logo.svg

Lines changed: 92 additions & 2 deletions
Loading

src/DataStax.AstraDB.DataApi/DataStax.AstraDB.DataApi.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,28 @@
55
<ImplicitUsings>disable</ImplicitUsings>
66
<Nullable>disable</Nullable>
77
<LangVersion>10.0</LangVersion>
8+
9+
<PackageId>DataStax.AstraDB.DataApi</PackageId>
10+
<Version>1.0.0</Version>
11+
<Authors>DataStax</Authors>
12+
<Company>DataStax</Company>
13+
<Description>Client library for accessing the DataStax Astra DB Data API from .NET applications.</Description>
14+
<Copyright>Copyright (c) DataStax 2025</Copyright>
15+
<PackageTags>astradb;datastax;serverless;dataapi</PackageTags>
16+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
17+
<PackageProjectUrl>https://docs.datastax.com/en/astra-db-serverless</PackageProjectUrl>
18+
<RepositoryUrl>https://github.com/datastax/astra-db-csharp</RepositoryUrl>
19+
<RepositoryType>git</RepositoryType>
20+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
21+
<PackageIcon>packageIcon.png</PackageIcon>
22+
<Readme>README.md</Readme>
823
</PropertyGroup>
924

25+
<ItemGroup>
26+
<None Include="packageIcon.png" Pack="true" PackagePath="\" />
27+
<None Include="README.md" Pack="true" PackagePath="\" />
28+
</ItemGroup>
29+
1030
<ItemGroup>
1131
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
1232
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Overview
2+
3+
This C# Client Library simplifies using the DataStax Data API to manage and interact with AstraDB instances as well as other DataStax databases.
4+
5+
# Installation
6+
7+
```
8+
dotnet add package DataStax.AstraDB.DataApi
9+
```
10+
11+
# Quickstart
12+
13+
```
14+
//instantiate a client
15+
var client = new DataApiClient("YourTokenHere");
16+
17+
//connect to a database
18+
var database = client.GetDatabase("YourDatabaseUrlHere");
19+
20+
//create a new collection
21+
var collection = await database.CreateCollectionAsync<SimpleObject>("YourCollectionNameHere");
22+
23+
//insert a document into the collection
24+
var documents = new List<SimpleObject>
25+
{
26+
new SimpleObject()
27+
{
28+
Name = "Test Object 1",
29+
},
30+
new SimpleObject()
31+
{
32+
Name = "Test Object 2",
33+
}
34+
};
35+
var insertResult = await collection.InsertManyAsync(documents);
36+
37+
//find a document
38+
var filter = Builders<SimpleObject>.Filter.Eq(so => so.Name, "Test Object 1");
39+
var results = await collection.Find(filter);
40+
```

src/DataStax.AstraDB.DataApi/Utils/Extensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Linq.Expressions;
2222
using System.Reflection;
2323
using System.Text;
24+
using System.Text.Json.Serialization;
2425

2526
namespace DataStax.AstraDB.DataApi.Utils;
2627

@@ -64,14 +65,18 @@ private static void BuildPropertyName(MemberExpression memberExpression, StringB
6465
var name = memberExpression.Member.Name;
6566
if (memberExpression.Member is PropertyInfo propertyInfo)
6667
{
68+
var jsonPropertyNameAttribute = propertyInfo.GetCustomAttribute<JsonPropertyNameAttribute>();
69+
if (jsonPropertyNameAttribute != null)
70+
{
71+
name = jsonPropertyNameAttribute.Name;
72+
}
6773
var attribute = propertyInfo.GetCustomAttribute<DocumentMappingAttribute>();
6874
if (attribute != null && attribute.Field == DocumentMappingField.Id)
6975
{
7076
name = DataApiKeywords.Id;
7177
}
7278
}
7379
sb.Append(name);
74-
7580
}
7681

7782
}
1.64 KB
Loading

0 commit comments

Comments
 (0)