0

I have 2 entities:

[TableName("is_userrole")]



public class UserRole
  {
      [MapField("id"), PrimaryKey, Identity,
      public Guid id;
      [NotNull]
      public string Name;       
  }    
[TableName("is_users")]
  public class User
  {
      [MapField("id"), PrimaryKey, Identity,
NonUpdatable]
      public Guid Id;
      [NotNull]
      public string Name;
      [NotNull]
      public string Login;
      [NotNull]
      public string Password;

      public Guid UserRole_Id;    
      [Association(ThisKey = "UserRole_Id", OtherKey = "Id",
CanBeNull = false)]
      public UserRole UserRole;
  }    

and stored procedure on sql server which gets data from query

[Select u., r. from is_users u inner join is_userrole r on u.userrole_id = r.id]

if i use linq query like

var query = from u in db.User select new { u.Id, u.Login, u.Password, u.UserRole_Id, u.UserRole };

Associations filling, but if I execute procedure only parent object(i.e. user) filled.
How in bltoolkit.net associations with stored procedures made? Or it can be only manually realised?

Thanks.

Black Moon
  • 1
  • 2
  • 6

2 Answers2

0

AssosiationAttribute is used only for Linq expressions.

Point to know: BLT does NO "hidden" actions, for ex. if you will change your linq code as: db.User.ToList() you'll see that UserProperty is not filled. In your sample filling is done because you have said to done it in select clausue, and Association is used only to build proper 'INNER JOIN' in SQL.

ili
  • 722
  • 1
  • 4
  • 15
0

Ok so I don't have any experience with this but I quickly looked at the unit-tests and it looks like MapResultSet could help you

the unit test are here -> UnitTests\CS\Mapping\ResultSetTest.cs

David DV
  • 674
  • 4
  • 9
  • I have SP - SelectByLogin(string) and public abstract class UserAccessor : gosDBAccessor { public abstract User SelectByLogin(string @login); } This SP has complex query with INNER JOIN in it. Execution - UserAccessor ua = DataAccessor.CreateInstance(); User user = ua.SelectByLogin(Login); This user doesn't have UserRole property filled. Where is the place for mapset include in code? – Black Moon Mar 26 '12 at 12:20
  • Really don't understand your question here, did you take a look at the unit tests? – David DV Mar 26 '12 at 13:37