开发者

Subsonic 3 Foreign Key with Class relationship issue

i´m using LINQ with the subsonic in a class to get my data here is the code below:

public IQueryable<Veiculo> SelecionaVeiculosSite() 
        {
                   return (from v in _db.Veiculos
                   开发者_运维问答         where v.Ativo == true &&
                            v.Marca.Ativo == true && 
                            v.Modelo.Ativo == true
                            select v
                           );            

        }

You will see one difference in line at "v.Marca.Ativo == true", I did one modification in template of ActiveRecord to get a and not a IQueryable. That the way i founded to make Classes relations based on the Foreign Keys of my database.

This is the code modified in the template (generated):

public Marca Marca
        {
            get
            {

                  var repo=OKMMySql.Marca.GetRepo();
                  return (from items in repo.GetAll()
                       where items.ID_Marca == _ID_Marca
                       select items).SingleOrDefault();
            }
        }

in the Code it´s ok, but this Select return this Execution time Error:

The binary operator Equal is not defined for the types 'System.Nullable`1[System.Int32]' and 'System.Int32'.

Anybody have any idea or anything to help my with this?

Many Thanks


One of your columns is nullable, it would seem. Go look in the class generated and see which one it is, or look at your database schema.

If it doesn't need to be nullable, then just remove that from the column and re-run the .tt file.


Andrew,

this works for me i just put NotNull FLAG in the INT fields in the Database and it´s solve this BUG for me

Many Thanks

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜