<@U0A71G31CDV> I have a quick question about .NET....
# questions-and-troubleshooting
a
@Rocky I have a quick question about .NET. Do you know if there are any plans on the roadmap to introduce support for the
datetimeoffset
type and DTO mapping in .NET?
r
Hi! Rocky here. Great question about .NET and StarRocks! Currently, StarRocks does not have a native
datetimeoffset
data type equivalent to the one found in SQL Server. The primary temporal types supported are DATE and DATETIME (which, as of v3.3.5, supports microsecond precision). Because StarRocks is MySQL-compatible, the roadmap for .NET support generally aligns with maintaining compatibility with standard MySQL drivers (like
MySqlConnector
) and ORMs (like Entity Framework Core with the
Pomelo.EntityFrameworkCore.MySql
provider). Here is the current status regarding your question: 1.
datetimeoffset
Support
Since StarRocks
DATETIME
is timezone-agnostic (it stores the date and time as provided without an internal offset), there isn't a direct native mapping for .NET's
DateTimeOffset
. Current Workarounds: * UTC Mapping: The most common practice in .NET is to convert
DateTimeOffset
to UTC in your application layer or DTO and store it in a StarRocks
DATETIME
column. * String Storage: If preserving the specific local offset is critical for your business logic, some users store the value as a
VARCHAR
or use two columns (one
DATETIME
for the timestamp and one
SMALLINT
for the offset in minutes). 2. DTO Mapping in .NET If you are using Entity Framework Core, you can handle this today using Value Converters. This allows you to automatically map a
DateTimeOffset
property in your DTO to a
DATETIME
column in StarRocks:
Copy code
csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<MyDto>()
        .Property(e => e.CreatedAt)
        .HasConversion(
            v => v.UtcDateTime, // To Store (UTC)
            v => new DateTimeOffset(v, TimeSpan.Zero) // To Read
        );
}
3. Roadmap There is no specific mention in the official StarRocks documentation of a dedicated .NET-native driver or a
datetimeoffset
type being introduced in the immediate roadmap. The project's focus for .NET remains on ensuring seamless integration through the MySQL wire protocol. If your use case requires specific native handling, I recommend checking the StarRocks GitHub to see if there are community-led discussions or to open a feature request! Let me know if you need help with anything else! Referencesintegrations/smt/starrocks_sqlalchemy.mddata_source/feature-support-data-lake-analytics.md