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

Enhance Insert(object poco) #64

Closed
dotnetchris opened this issue Jul 22, 2011 · 3 comments
Closed

Enhance Insert(object poco) #64

dotnetchris opened this issue Jul 22, 2011 · 3 comments

Comments

@dotnetchris
Copy link

I recommend enhancing this method

public object Insert(object poco)
{
    var pd = PocoData.ForType(poco.GetType());
    return Insert(pd.TableInfo.TableName, pd.TableInfo.PrimaryKey, pd.TableInfo.AutoIncrement, poco);
}

to

public object Insert(object poco, string tableName = null, string primaryKeyName = null, bool? autoIncrement = null)
{
    var pd = PocoData.ForType(poco.GetType());
    return Insert(tableName  ?? pd.TableInfo.TableName,primaryKeyName  ?? pd.TableInfo.PrimaryKey, (autoIncrement ?? (bool?)pd.TableInfo.AutoIncrement).Value, poco);
}

This would also potentially make the other methods redundant, other than potentially the full expanded method to skip the cost of calling PocoData.ForType

@schotime
Copy link

schotime commented Aug 4, 2011

Firstly, default parameters are only supported in .net 4.0 and this library currently maintains support for 3.5.
Also, doing a PocoData.ForType() is cheap after the first time as it is cached.

@dotnetchris
Copy link
Author

If that's the goal to support legacy .NET frameworks then that makes the value of #65 even greater since that means I can write an Extension class that uses optional parameters etc.

@pleb pleb added the discussion label Dec 4, 2015
@pleb
Copy link
Member

pleb commented Dec 5, 2015

I'm sorry that your issue has been left for so long. In an effort to reboot PetaPoco your issue has been closed. If you think this is still a problem. Please feel free to open and another issue. Please pass the word on that PetaPoco is back. We're looking for people #204.

@pleb pleb closed this as completed Dec 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants