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

Added support for multiple schemas within a database, and support for get/delete for tables without an int primary key #9

Merged
merged 8 commits into from Dec 19, 2013

Conversation

psantiago
Copy link
Contributor

This also required changing the testing database from SqlCE to localDB, as SqlCE doesn't support multiple schemas per database (which of course made that feature untestable).

…ead of an int

This lets us use a string as a primary key without needing to write
custom inserts
This keeps from having to change existing implementations, while still
supporting additional key types. Since the key is only used as an object
anyway, there shouldn't be any type concerns anyway really.
Conflicts:
	Dapper.SimpleCRUD/SimpleCRUD.cs
Added some tests which required switching the test db (now uses LocalDB)
as SqlCE doens't support multiple schemas.
Fixed an issue where some table attributes may not include the schema
property.
ericdc1 added a commit that referenced this pull request Dec 19, 2013
Added support for multiple schemas within a database, and support for get/delete for tables without an int primary key
@ericdc1 ericdc1 merged commit d794150 into ericdc1:master Dec 19, 2013
@ericdc1
Copy link
Owner

ericdc1 commented Dec 19, 2013

Thanks!

@mxmissile
Copy link

mxmissile commented May 29, 2018

How do you specify dbo in the schema using TableAttribute?

[Table("PhotoGallery_photos",Schema = "portal.dbo")] generates [portal.dbo].[PhotoGallery_photos] which does not work.

desired: portal.dbo.[PhotoGallery_photos]

@ericdc1
Copy link
Owner

ericdc1 commented May 30, 2018

See the tests: https://github.com/ericdc1/Dapper.SimpleCRUD/blob/master/Dapper.SimpleCRUDTests/Tests.cs#L83

[Table("CarLog", Schema = "Log")]
public class CarLog
{
    public int Id { get; set; }
    public string LogNotes { get; set; }
}


    public void TestInsertIntoDifferentSchema()
    {
        using (var connection = GetOpenConnection())
        {
            var id = connection.Insert(new CarLog { LogNotes = "blah blah blah" });
            id.IsEqualTo(1);
            connection.Delete<CarLog>(id);

        }
    }

@mxmissile
Copy link

Adding the db element breaks that test: [Table("CarLog", Schema = "Log.dbo")]

@psantiago
Copy link
Contributor Author

@mxmissile - assuming this is for SQL Server, I believe portal.dbo.photogallery_photos would refer to a different database portal, with the schema dbo and table photogallery_photos (ie, not a different schema within the database). The schema attribute is intended for use of multiple schemas within a database, see https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/ownership-and-user-schema-separation-in-sql-server

@mxmissile
Copy link

I see. I got it to work using a different db connection, or writing my own query. Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants