add missing find method

This commit is contained in:
Pilzinsel64
2025-04-02 07:54:00 +02:00
parent 96ee827239
commit 8050a4c2f5
2 changed files with 17 additions and 5 deletions

View File

@@ -97,13 +97,24 @@ public abstract class DataManager : IDataManager
public virtual bool Find<T>(int id, [NotNullWhen(true)] out T? obj) where T : class, IDataObject
{
if (FindEntity<T>(id) is not T t)
if (Find<T>(id) is T t)
{
obj = default;
return false;
obj = t;
return true;
}
obj = t;
return true;
obj = default;
return false;
}
public virtual bool Find<T>(int? id, [NotNullWhen(true)] out T? obj) where T : class, IDataObject
{
if (Find<T>(id) is T t)
{
obj = t;
return true;
}
obj = default;
return false;
}
public virtual void Delete<T>(int id) where T : class, IDataObject

View File

@@ -11,6 +11,7 @@ public interface IDataManager
T? Find<T>(int id) where T : class, IDataObject;
bool Find<T>(int id, [NotNullWhen(true)] out T? obj) where T : class, IDataObject;
T? Find<T>(int? id) where T : class, IDataObject;
bool Find<T>(int? id, [NotNullWhen(true)] out T? obj) where T : class, IDataObject;
T FindOrNew<T>(int id) where T : class, IDataObject;
bool FindOrNew<T>(int id, [NotNullWhen(true)] out T? obj) where T : class, IDataObject;
T FindOrNew<T>(int? id) where T : class, IDataObject;