开发者

Can BLTookit Generate Db and Tables

开发者 https://www.devze.com 2023-04-07 18:10 出处:网络
I am currently using Entity Framework Code First to generate my MySQL tables and schema from my classes. However, I would like to switch to BlToolkit. Does this ORM support table generation from class

I am currently using Entity Framework Code First to generate my MySQL tables and schema from my classes. However, I would like to switch to BlToolkit. Does this ORM support table generation from classes decorated with various attributes? If so, can you give a quick example?

I was looking at editable object like this but wasn't sure:

 public abstract class TestObject : EditableObject<TestObject>
 {
     public abstract string FirstName { get; set; }
     public abstract string LastName  { get; set; }
 }
...

I've also seen this:

public abstract class PersonAccessor : DataAccessor
{
    [SqlText(@"SELECT * FROM Person WHERE FirstName = @firstName")]
    public abstract List<Person> GetPersonListByFirstName(string @firstName);

    [SprocName("sp_GetPersonListByLastName")]
    public abstract List<Person> GetPersonListByLastName(string @lastName);
    ...

But I'd rather not write the SQL.

I am using BLToo开发者_Python百科kit 4.0 with C# on Visual Studio 2010, with MySql 5.3

Thanks!


You can use T4 templates to generate the classes -> http://bltoolkit.net/Doc.T4Templates.ashx

And no, you don't have to write SQL just use the Linq Provider, check the documentation @ http://bltoolkit.net/Doc.Linq.ashx

Best is also to get the Full dev version which has loads of examples and unit tests


I don't know is it possible to created the database and tables with BLToolkit. This is what I would also like to know.

As of writing SQL in code, you don't need to do that. You can just write Linq queries for select, but for insert,update and delete the syntax is little different than in Linq2SQL or Linq2Entity, but when you start to use it you'l get used to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号