Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are Bulkoperations possible? #20

Open
janbiehl opened this issue Jan 4, 2025 · 0 comments
Open

Are Bulkoperations possible? #20

janbiehl opened this issue Jan 4, 2025 · 0 comments

Comments

@janbiehl
Copy link

janbiehl commented Jan 4, 2025

Hey, first i want to point out that i love the idea of this library and i recently discovered it. I have a question about bulk operations. Is there a chance to do bulk operations for example inserts?

Before i discovered this library i would have done it like below. I love the idea of doing just the formattable string thing and would like to adapt that also for the buk operations.

public async Task<ErrorOr<Success>> CreateBulkAsync(IReadOnlyCollection<RoleEntity> entities, 
CancellationToken cancellationToken = default)
{
	var parameters = entities.Select(entity => new
	{
		name = entity.Name,
		descriptioN = entity.Description
	});

	CommandDefinition definition = new ("""
	                                    INSERT INTO roles (name, description)
	                                    VALUES (@name, @description)
	                                    """, parameters);
	await Connection.ExecuteAsync(definition);

	return new Success();
}

If possible please point me to a example.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant