23 lines
568 B
C#
23 lines
568 B
C#
using System.Collections.Generic;
|
|
|
|
namespace Kit.Helpers.Extension.Entities
|
|
{
|
|
public interface IInt32Id
|
|
{
|
|
int Id { get; }
|
|
}
|
|
|
|
public static class IInt32IdExtentions
|
|
{
|
|
public static IDictionary<int, TObject> ConvertToDictionary<TObject>(this IEnumerable<TObject> objects)
|
|
where TObject : IInt32Id
|
|
{
|
|
var dictionary = new Dictionary<int, TObject>();
|
|
{
|
|
foreach (var obj in objects) dictionary.Add(obj.Id, obj);
|
|
}
|
|
return dictionary;
|
|
}
|
|
}
|
|
}
|