dotnetcore / dotnetcore/FreeSql

如何实现存在就不插入的功能

Open
#2,062 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

``` csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FreeSql.DataAnnotations;
using renyimen.Models;

namespace renyimen.Model
{
[Table(Name = "schedule")]
public class Schedule
{
///
/// 演出时间表主键ID
///
///
[Column(IsPrimary = true, IsIdentity = true)]
public int ScheduleId { get; set; }

///
/// 门店ID,用于关联
///
///
public int VenueId { get; set; }

///
/// 演出ID,用于关联
///
///
public int PerformanceId { get; set; }

///
/// 排版表的日期
///
///
public DateOnly ScheduleDate { get; set; }

///
/// 演出开始时间
///
public TimeSpan StartTime { get; set; }

///
/// 演出结束时间
///
public TimeSpan EndTime { get; set; }

///
/// 这个班次中的初始可预约人数
///
public int TotalBookingCount { get; set; }

///
/// 当前预约人数
///
public int CurrentBookingCount { get; set; }

///
/// 剩余可预约人数
///
public int RemainingBookingCount { get; set; }

///
/// 是否可预约,数据库忽略此字段
///
[Column(IsIgnore = true)]
public bool IsReservable { get; set; } = true;

///
/// 关联的门店信息
///
[Navigate("VenueId")]
public required virtual PerformanceVenue PerformanceVenue { get; set; }
}
}
```
我希望插入的时候如果查询到 ScheduleDate = 今天,明天。有返回值的情况下就不插入,如果没有返回值就插入。应该如何实现

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.