Skip to content

Commit

Permalink
Merge branch 'dynamicIndexType' of https://github.com/hyzx86/yessql i…
Browse files Browse the repository at this point in the history
…nto dynamicIndexType
  • Loading branch information
hyzx86 committed Jan 2, 2024
2 parents 212a333 + 16acf5e commit c40413d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/YesSql.Abstractions/IStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@ public interface IStore : IDisposable
/// Returns the <see cref="ITypeService" /> instance used to create this store.
/// </summary>
ITypeService TypeNames { get; }

}
}
5 changes: 1 addition & 4 deletions src/YesSql.Abstractions/Indexes/DescribeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public IMapFor<T, TIndex> For<TIndex>() where TIndex : IIndex
return For<TIndex, object>(typeof(TIndex));
}

public IMapFor<T, TIndex> For<TIndex, TKey>() where TIndex : IIndex
{
return For<TIndex, object>(typeof(TIndex));
}
public IMapFor<T, TIndex> For<TIndex, TKey>() where TIndex : IIndex => For<TIndex, object>(typeof(TIndex));

public IMapFor<T, TIndex> For<TIndex, TKey>(Type indexType) where TIndex : IIndex
{
Expand Down
6 changes: 2 additions & 4 deletions src/YesSql.Abstractions/Indexes/IndexTypeCacheProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ public class IndexTypeCacheProvider
private static readonly ConcurrentDictionary<PropertyInfo, PropertyInfoAccessor> PropertyAccessors = new();
private static readonly ConcurrentDictionary<Type, PropertyInfo[]> TypeProperties = new();

public virtual PropertyInfoAccessor GetPropertyAccessor(PropertyInfo property)
{
return PropertyAccessors.GetOrAdd(property, p => new PropertyInfoAccessor(p));
}
public virtual PropertyInfoAccessor GetPropertyAccessor(PropertyInfo property) => PropertyAccessors.GetOrAdd(property, p => new PropertyInfoAccessor(p));

public virtual PropertyInfo[] GetTypeProperties(Type type)
{
Expand All @@ -26,6 +23,7 @@ public virtual PropertyInfo[] GetTypeProperties(Type type)

var properties = type.GetProperties().Where(IsWriteable).ToArray();
TypeProperties[type] = properties;

return properties;
}

Expand Down
3 changes: 2 additions & 1 deletion src/YesSql.Core/Commands/IndexCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public abstract class IndexCommand : IIndexCommand
{
private const string _separator = ", ";
protected const string ParameterSuffix = "_$$$";
protected static PropertyInfo[] KeysProperties = [typeof(IIndex).GetProperty("Id")];

private static IndexTypeCacheProvider IndexTypeCacheProvider;
protected static PropertyInfo[] KeysProperties = [typeof(IIndex).GetProperty("Id")];

private static readonly ConcurrentDictionary<CompoundKey, string> InsertsList = new();
private static readonly ConcurrentDictionary<CompoundKey, string> UpdatesList = new();
Expand Down
1 change: 1 addition & 0 deletions test/YesSql.Tests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6357,6 +6357,7 @@ await builder

await session.SaveAsync(property);
await session.SaveChangesAsync();

var testProperties = await session.Query<Property, PropertyIndex>(x => x.Id == 1).ListAsync();
Assert.NotEmpty(testProperties);
session.Dispose();
Expand Down

0 comments on commit c40413d

Please sign in to comment.