Skip to content

Commit d20cafa

Browse files
authored
Cleanup unneeded code (#246)
* remove some unnecessary stuff
1 parent 2d5930a commit d20cafa

File tree

9 files changed

+165
-528
lines changed

9 files changed

+165
-528
lines changed

src/EFCore.Jet/Extensions/JetModelExtensions.cs

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -126,95 +126,5 @@ public static void SetValueGenerationStrategy(
126126
/// <returns> The <see cref="ConfigurationSource" /> for the default <see cref="JetValueGenerationStrategy" />. </returns>
127127
public static ConfigurationSource? GetJetValueGenerationStrategyConfigurationSource([NotNull] this IConventionModel model)
128128
=> model.FindAnnotation(JetAnnotationNames.ValueGenerationStrategy)?.GetConfigurationSource();
129-
130-
/// <summary>
131-
/// Returns the suffix to append to the name of automatically created sequences.
132-
/// </summary>
133-
/// <param name="model">The model.</param>
134-
/// <returns>The name to use for the default key value generation sequence.</returns>
135-
public static string GetJetSequenceNameSuffix(this IReadOnlyModel model)
136-
=> (string?)model[JetAnnotationNames.SequenceNameSuffix]
137-
?? DefaultSequenceNameSuffix;
138-
139-
/// <summary>
140-
/// Sets the suffix to append to the name of automatically created sequences.
141-
/// </summary>
142-
/// <param name="model">The model.</param>
143-
/// <param name="name">The value to set.</param>
144-
public static void SetJetSequenceNameSuffix(this IMutableModel model, string? name)
145-
{
146-
Check.NullButNotEmpty(name, nameof(name));
147-
148-
model.SetOrRemoveAnnotation(JetAnnotationNames.SequenceNameSuffix, name);
149-
}
150-
151-
/// <summary>
152-
/// Sets the suffix to append to the name of automatically created sequences.
153-
/// </summary>
154-
/// <param name="model">The model.</param>
155-
/// <param name="name">The value to set.</param>
156-
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
157-
/// <returns>The configured value.</returns>
158-
public static string? SetJetSequenceNameSuffix(
159-
this IConventionModel model,
160-
string? name,
161-
bool fromDataAnnotation = false)
162-
=> (string?)model.SetOrRemoveAnnotation(
163-
JetAnnotationNames.SequenceNameSuffix,
164-
Check.NullButNotEmpty(name, nameof(name)),
165-
fromDataAnnotation)?.Value;
166-
167-
/// <summary>
168-
/// Returns the <see cref="ConfigurationSource" /> for the default value generation sequence name suffix.
169-
/// </summary>
170-
/// <param name="model">The model.</param>
171-
/// <returns>The <see cref="ConfigurationSource" /> for the default key value generation sequence name.</returns>
172-
public static ConfigurationSource? GetJetSequenceNameSuffixConfigurationSource(this IConventionModel model)
173-
=> model.FindAnnotation(JetAnnotationNames.SequenceNameSuffix)?.GetConfigurationSource();
174-
175-
/// <summary>
176-
/// Returns the schema to use for the default value generation sequence.
177-
/// <see cref="JetPropertyBuilderExtensions.UseSequence" />
178-
/// </summary>
179-
/// <param name="model">The model.</param>
180-
/// <returns>The schema to use for the default key value generation sequence.</returns>
181-
public static string? GetJetSequenceSchema(this IReadOnlyModel model)
182-
=> (string?)model[JetAnnotationNames.SequenceSchema];
183-
184-
/// <summary>
185-
/// Sets the schema to use for the default key value generation sequence.
186-
/// </summary>
187-
/// <param name="model">The model.</param>
188-
/// <param name="value">The value to set.</param>
189-
public static void SetJetSequenceSchema(this IMutableModel model, string? value)
190-
{
191-
Check.NullButNotEmpty(value, nameof(value));
192-
193-
model.SetOrRemoveAnnotation(JetAnnotationNames.SequenceSchema, value);
194-
}
195-
196-
/// <summary>
197-
/// Sets the schema to use for the default key value generation sequence.
198-
/// </summary>
199-
/// <param name="model">The model.</param>
200-
/// <param name="value">The value to set.</param>
201-
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
202-
/// <returns>The configured value.</returns>
203-
public static string? SetJetSequenceSchema(
204-
this IConventionModel model,
205-
string? value,
206-
bool fromDataAnnotation = false)
207-
=> (string?)model.SetOrRemoveAnnotation(
208-
JetAnnotationNames.SequenceSchema,
209-
Check.NullButNotEmpty(value, nameof(value)),
210-
fromDataAnnotation)?.Value;
211-
212-
/// <summary>
213-
/// Returns the <see cref="ConfigurationSource" /> for the default key value generation sequence schema.
214-
/// </summary>
215-
/// <param name="model">The model.</param>
216-
/// <returns>The <see cref="ConfigurationSource" /> for the default key value generation sequence schema.</returns>
217-
public static ConfigurationSource? GetJetSequenceSchemaConfigurationSource(this IConventionModel model)
218-
=> model.FindAnnotation(JetAnnotationNames.SequenceSchema)?.GetConfigurationSource();
219129
}
220130
}

src/EFCore.Jet/Extensions/JetPropertyExtensions.cs

Lines changed: 0 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -376,177 +376,5 @@ private static bool IsCompatibleWithValueGeneration(
376376
return (type.IsInteger()
377377
|| type == typeof(decimal));
378378
}
379-
380-
/// <summary>
381-
/// Returns the name to use for the key value generation sequence.
382-
/// </summary>
383-
/// <param name="property">The property.</param>
384-
/// <returns>The name to use for the key value generation sequence.</returns>
385-
public static string? GetJetSequenceName(this IReadOnlyProperty property)
386-
=> (string?)property[JetAnnotationNames.SequenceName];
387-
388-
/// <summary>
389-
/// Returns the name to use for the key value generation sequence.
390-
/// </summary>
391-
/// <param name="property">The property.</param>
392-
/// <param name="storeObject">The identifier of the store object.</param>
393-
/// <returns>The name to use for the key value generation sequence.</returns>
394-
public static string? GetJetSequenceName(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
395-
{
396-
var annotation = property.FindAnnotation(JetAnnotationNames.SequenceName);
397-
if (annotation != null)
398-
{
399-
return (string?)annotation.Value;
400-
}
401-
402-
return property.FindSharedStoreObjectRootProperty(storeObject)?.GetJetSequenceName(storeObject);
403-
}
404-
405-
/// <summary>
406-
/// Sets the name to use for the key value generation sequence.
407-
/// </summary>
408-
/// <param name="property">The property.</param>
409-
/// <param name="name">The sequence name to use.</param>
410-
public static void SetJetSequenceName(this IMutableProperty property, string? name)
411-
=> property.SetOrRemoveAnnotation(
412-
JetAnnotationNames.SequenceName,
413-
Check.NullButNotEmpty(name, nameof(name)));
414-
415-
/// <summary>
416-
/// Sets the name to use for the key value generation sequence.
417-
/// </summary>
418-
/// <param name="property">The property.</param>
419-
/// <param name="name">The sequence name to use.</param>
420-
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
421-
/// <returns>The configured value.</returns>
422-
public static string? SetJetSequenceName(
423-
this IConventionProperty property,
424-
string? name,
425-
bool fromDataAnnotation = false)
426-
=> (string?)property.SetOrRemoveAnnotation(
427-
JetAnnotationNames.SequenceName,
428-
Check.NullButNotEmpty(name, nameof(name)),
429-
fromDataAnnotation)?.Value;
430-
431-
/// <summary>
432-
/// Returns the <see cref="ConfigurationSource" /> for the key value generation sequence name.
433-
/// </summary>
434-
/// <param name="property">The property.</param>
435-
/// <returns>The <see cref="ConfigurationSource" /> for the key value generation sequence name.</returns>
436-
public static ConfigurationSource? GetJetSequenceNameConfigurationSource(this IConventionProperty property)
437-
=> property.FindAnnotation(JetAnnotationNames.SequenceName)?.GetConfigurationSource();
438-
439-
/// <summary>
440-
/// Returns the schema to use for the key value generation sequence.
441-
/// </summary>
442-
/// <param name="property">The property.</param>
443-
/// <returns>The schema to use for the key value generation sequence.</returns>
444-
public static string? GetJetSequenceSchema(this IReadOnlyProperty property)
445-
=> (string?)property[JetAnnotationNames.SequenceSchema];
446-
447-
/// <summary>
448-
/// Returns the schema to use for the key value generation sequence.
449-
/// </summary>
450-
/// <param name="property">The property.</param>
451-
/// <param name="storeObject">The identifier of the store object.</param>
452-
/// <returns>The schema to use for the key value generation sequence.</returns>
453-
public static string? GetJetSequenceSchema(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
454-
{
455-
var annotation = property.FindAnnotation(JetAnnotationNames.SequenceSchema);
456-
if (annotation != null)
457-
{
458-
return (string?)annotation.Value;
459-
}
460-
461-
return property.FindSharedStoreObjectRootProperty(storeObject)?.GetJetSequenceSchema(storeObject);
462-
}
463-
464-
/// <summary>
465-
/// Sets the schema to use for the key value generation sequence.
466-
/// </summary>
467-
/// <param name="property">The property.</param>
468-
/// <param name="schema">The schema to use.</param>
469-
public static void SetJetSequenceSchema(this IMutableProperty property, string? schema)
470-
=> property.SetOrRemoveAnnotation(
471-
JetAnnotationNames.SequenceSchema,
472-
Check.NullButNotEmpty(schema, nameof(schema)));
473-
474-
/// <summary>
475-
/// Sets the schema to use for the key value generation sequence.
476-
/// </summary>
477-
/// <param name="property">The property.</param>
478-
/// <param name="schema">The schema to use.</param>
479-
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
480-
/// <returns>The configured value.</returns>
481-
public static string? SetJetSequenceSchema(
482-
this IConventionProperty property,
483-
string? schema,
484-
bool fromDataAnnotation = false)
485-
=> (string?)property.SetOrRemoveAnnotation(
486-
JetAnnotationNames.SequenceSchema,
487-
Check.NullButNotEmpty(schema, nameof(schema)),
488-
fromDataAnnotation)?.Value;
489-
490-
/// <summary>
491-
/// Returns the <see cref="ConfigurationSource" /> for the key value generation sequence schema.
492-
/// </summary>
493-
/// <param name="property">The property.</param>
494-
/// <returns>The <see cref="ConfigurationSource" /> for the key value generation sequence schema.</returns>
495-
public static ConfigurationSource? GetGetSequenceSchemaConfigurationSource(this IConventionProperty property)
496-
=> property.FindAnnotation(JetAnnotationNames.SequenceSchema)?.GetConfigurationSource();
497-
498-
/// <summary>
499-
/// Finds the <see cref="ISequence" /> in the model to use for the key value generation pattern.
500-
/// </summary>
501-
/// <param name="property">The property.</param>
502-
/// <returns>The sequence to use, or <see langword="null" /> if no sequence exists in the model.</returns>
503-
public static IReadOnlySequence? FindJetSequence(this IReadOnlyProperty property)
504-
{
505-
var model = property.DeclaringType.Model;
506-
507-
var sequenceName = property.GetJetSequenceName()
508-
?? model.GetJetSequenceNameSuffix();
509-
510-
var sequenceSchema = property.GetJetSequenceSchema()
511-
?? model.GetJetSequenceSchema();
512-
513-
return model.FindSequence(sequenceName, sequenceSchema);
514-
}
515-
516-
/// <summary>
517-
/// Finds the <see cref="ISequence" /> in the model to use for the key value generation pattern.
518-
/// </summary>
519-
/// <param name="property">The property.</param>
520-
/// <param name="storeObject">The identifier of the store object.</param>
521-
/// <returns>The sequence to use, or <see langword="null" /> if no sequence exists in the model.</returns>
522-
public static IReadOnlySequence? FindJetSequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
523-
{
524-
var model = property.DeclaringType.Model;
525-
526-
var sequenceName = property.GetJetSequenceName(storeObject)
527-
?? model.GetJetSequenceNameSuffix();
528-
529-
var sequenceSchema = property.GetJetSequenceSchema(storeObject)
530-
?? model.GetJetSequenceSchema();
531-
532-
return model.FindSequence(sequenceName, sequenceSchema);
533-
}
534-
535-
/// <summary>
536-
/// Finds the <see cref="ISequence" /> in the model to use for the key value generation pattern.
537-
/// </summary>
538-
/// <param name="property">The property.</param>
539-
/// <returns>The sequence to use, or <see langword="null" /> if no sequence exists in the model.</returns>
540-
public static ISequence? FindJetSequence(this IProperty property)
541-
=> (ISequence?)((IReadOnlyProperty)property).FindJetSequence();
542-
543-
/// <summary>
544-
/// Finds the <see cref="ISequence" /> in the model to use for the key value generation pattern.
545-
/// </summary>
546-
/// <param name="property">The property.</param>
547-
/// <param name="storeObject">The identifier of the store object.</param>
548-
/// <returns>The sequence to use, or <see langword="null" /> if no sequence exists in the model.</returns>
549-
public static ISequence? FindJetSequence(this IProperty property, in StoreObjectIdentifier storeObject)
550-
=> (ISequence?)((IReadOnlyProperty)property).FindJetSequence(storeObject);
551379
}
552380
}

src/EFCore.Jet/Metadata/Conventions/JetValueGenerationStrategyConvention.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ public virtual void ProcessModelFinalizing(
8484
&& declaringTable.Name != null)
8585
{
8686
property.Builder.HasValueGenerationStrategy(strategy);
87-
88-
if (strategy == JetValueGenerationStrategy.Sequence)
89-
{
90-
var sequence = modelBuilder.HasSequence(
91-
property.GetJetSequenceName(declaringTable)
92-
?? entityType.GetRootType().ShortName() + modelBuilder.Metadata.GetJetSequenceNameSuffix(),
93-
property.GetJetSequenceSchema(declaringTable)
94-
?? modelBuilder.Metadata.GetJetSequenceSchema()).Metadata;
95-
96-
property.Builder.HasDefaultValueSql(
97-
RelationalDependencies.UpdateSqlGenerator.GenerateObtainNextSequenceValueOperation(
98-
sequence.Name, sequence.Schema));
99-
}
10087
}
10188
}
10289
}

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetByteArrayMethodTranslator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public JetByteArrayMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
4949
{
5050
if (method == ByteArrayLength)
5151
{
52-
var isBinaryMaxDataType = GetProviderType(arguments[1]) == "varbinary(max)" || arguments[1] is SqlParameterExpression;
52+
var isBinaryMaxDataType = arguments[1] is SqlParameterExpression;
5353
SqlExpression dataLengthSqlFunction = _sqlExpressionFactory.Function(
5454
"LENB",
5555
new[] { arguments[1] },

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetStringMethodTranslator.cs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -301,29 +301,12 @@ private SqlExpression TranslateIndexOf(
301301

302302
var argumentsPropagateNullability = Enumerable.Repeat(true, charIndexArguments.Count);
303303

304-
SqlExpression charIndexExpression;
305-
var storeType = stringTypeMapping.StoreType;
306-
if (string.Equals(storeType, "nvarchar(max)", StringComparison.OrdinalIgnoreCase)
307-
|| string.Equals(storeType, "varchar(max)", StringComparison.OrdinalIgnoreCase))
308-
{
309-
charIndexExpression = _sqlExpressionFactory.Function(
310-
"INSTR",
311-
charIndexArguments,
312-
nullable: true,
313-
argumentsPropagateNullability,
314-
typeof(long));
315-
316-
charIndexExpression = _sqlExpressionFactory.Convert(charIndexExpression, typeof(int));
317-
}
318-
else
319-
{
320-
charIndexExpression = _sqlExpressionFactory.Function(
321-
"INSTR",
322-
charIndexArguments,
323-
nullable: true,
324-
argumentsPropagateNullability,
325-
method.ReturnType);
326-
}
304+
SqlExpression charIndexExpression = charIndexExpression = _sqlExpressionFactory.Function(
305+
"INSTR",
306+
charIndexArguments,
307+
nullable: true,
308+
argumentsPropagateNullability,
309+
method.ReturnType);
327310

328311
charIndexExpression = _sqlExpressionFactory.Subtract(charIndexExpression, _sqlExpressionFactory.Constant(1));
329312

src/EFCore.Jet/Storage/Internal/JetTypeMappingSource.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public JetTypeMappingSource(
104104
{"binary", new []{_fixedLengthBinary}},
105105

106106
{"varbinary", new []{_variableLengthBinary}},
107-
{"varbinary(max)", new[] { _variableLengthMaxBinary }},
108107
{"binary varying", new[] { _variableLengthBinary }},
109108
{"bit varying", new[] { _variableLengthBinary }},
110109

@@ -172,13 +171,6 @@ public JetTypeMappingSource(
172171
{"national char varying", new[] { _variableLengthUnicodeString }},
173172
{"national character varying", new[] { _variableLengthUnicodeString }},
174173

175-
{"varchar(max)", new[] { _variableLengthMaxUnicodeString }},
176-
{"string(max)", new[] { _variableLengthMaxUnicodeString }},
177-
{"char varying(max)", new[] { _variableLengthMaxUnicodeString }},
178-
{"character varying(max)", new[] { _variableLengthMaxUnicodeString }},
179-
{"national char varying(max)", new[] { _variableLengthMaxUnicodeString }},
180-
{"national character varying(max)", new[] { _variableLengthMaxUnicodeString }},
181-
182174
{"longchar", new[] { _unboundedUnicodeString }},
183175
{"longtext", new[] { _unboundedUnicodeString }},
184176
{"memo", new[] { _unboundedUnicodeString }},

0 commit comments

Comments
 (0)