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 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; obj = t;
return false; return true;
} }
obj = t; obj = default;
return true; 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 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; T? Find<T>(int id) where T : class, IDataObject;
bool Find<T>(int id, [NotNullWhen(true)] out T? obj) 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; 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; T FindOrNew<T>(int id) where T : class, IDataObject;
bool FindOrNew<T>(int id, [NotNullWhen(true)] out T? obj) 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; T FindOrNew<T>(int? id) where T : class, IDataObject;