-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 doc comments for ValueGeneration.*
- Loading branch information
1 parent
fb4cad0
commit 5a9820a
Showing
13 changed files
with
224 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/EntityFramework.Core/ValueGeneration/TemporaryGuidValueGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Data.Entity.ValueGeneration | ||
{ | ||
/// <summary> | ||
/// Generates <see cref="Guid"/> values using <see cref="Guid.NewGuid()"/>. | ||
/// The generated values are temporary, meaning they will be replaced by database | ||
/// generated values when the entity is saved. | ||
/// </summary> | ||
public class TemporaryGuidValueGenerator : GuidValueGenerator | ||
{ | ||
/// <summary> | ||
/// Gets a value indicating whether the values generated are temporary or permanent. This implementation | ||
/// always returns true, meaning the generated values will be replaced by database generated values when | ||
/// the entity is saved | ||
/// </summary> | ||
public override bool GeneratesTemporaryValues => true; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/EntityFramework.Core/ValueGeneration/ValueGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Data.Entity.ValueGeneration | ||
{ | ||
/// <summary> | ||
/// Generates values for properties when an entity is added to a context. | ||
/// </summary> | ||
public abstract class ValueGenerator | ||
{ | ||
/// <summary> | ||
/// Gets a value to be assigned to a property. | ||
/// </summary> | ||
/// <returns> The value to be assigned to a property. </returns> | ||
public virtual object Next() => NextValue(); | ||
|
||
/// <summary> | ||
/// Template method to be overridden by implementations to perform value generation. | ||
/// </summary> | ||
/// <returns> The generated value. </returns> | ||
protected abstract object NextValue(); | ||
|
||
/// <summary> | ||
/// <para> | ||
/// Gets a value indicating whether the values generated are temporary (i.e they should be replaced | ||
/// by database generated values when the entity is saved) or are permanent (i.e. the generated values | ||
/// should be saved to the database). | ||
/// </para> | ||
/// <para> | ||
/// An example of temporary value generation is generating negative numbers for an integer primary key | ||
/// that are then replaced by positive numbers generated by the database when the entity is saved. An | ||
/// example of permanent value generation are client-generated values for a <see cref="Guid"/> primary | ||
/// key which are saved to the database. | ||
/// </para> | ||
/// </summary> | ||
public abstract bool GeneratesTemporaryValues { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.