Thanks, You helped me a lot. it's really much easier than i thought
On Wed, May 12, 2010 at 9:21 PM, Belvasis <[email protected]>wrote: > Hm...you should really read the documentation. It's all really simple. > > One possibility is using ICriterion: > > ICriterion[] pQuery = {Expression.Eq("PlayerName",userName)}; > > Game.FindAll(pQuery); > > or try HQL with SimpleQuery etc. > > But first you should deliberate about wheter ActiveRecord/NHibernate is > really the right solution for you > or not. > > > > 2010/5/12 Zvi Balas <[email protected]> > >> Thanks, >> that's helped me to do one of the things i need. >> but i now understand that i need more complex join. >> >> suppose we have two table: >> Board: >> int ID >> string Name >> int BoardSize >> >> game: >> int ID >> int BoardID >> string PlayerName >> string solveDate >> >> now, i want to join those two tables by the BoardID, and to display in >> datagrid to the user only the games he solved, >> and all the boards that he didn't solved yes. >> >> so i need a join that give me all the record from table Board with the >> records from table game where PlayerName = username. >> >> can you assist me with this also? >> >> Thanks a lot >> Zvi >> >> >> >> On Wed, May 12, 2010 at 2:52 AM, Belvasis <[email protected]>wrote: >> >>> You could use something like: >>> >>> [ActiveRecord("Game")] >>> class Game : ActiveRecordBase >>> { >>> [BelongsTo("BoardID")] >>> public Board OwnerBoard >>> { >>> get; >>> set; >>> } >>> } >>> >>> [ActiveRecord("Board")] >>> class Board : ActiveRecordBase >>> { >>> } >>> >>> Using one of the Find*(typeof(Game)) Methods you get an array of Games >>> with the correct OwnerBoard. >>> In this case you can simply bind Game.solveDate or Game.OwnerBoard.ID to >>> the datagrid, assuming >>> that the OwnerBoard never has a null value. >>> >>> For viewing purposes you can also simply build a view with the necessary >>> properties and map it to a >>> new class: >>> >>> [ActiveRecord("View_Game_Board")] >>> class ViewGame : ActiveRecordBase >>> { >>> } >>> >>> or simply use ADO.NET to show the data and for editing purposes or >>> something like that load the entity >>> via FindByPrimaryKey...Board.FindByPrimaryKey(BoardID). >>> >>> >>> 2010/5/11 Zvi Balas <[email protected]> >>> >>>> Thanks, >>>> but this is not exactly what i'm looking for. >>>> >>>> suppose we have two table: >>>> Board: >>>> int ID >>>> string Name >>>> int BoardSize >>>> >>>> game: >>>> int ID >>>> int BoardID >>>> string solveDate >>>> >>>> BoardID is ID of table Board. >>>> i have many entries in game that link to the same Board. >>>> >>>> i want to make a join that will return me a list with the following >>>> fields: >>>> gameID, BoardID, Name, BoardSize, SolveDate >>>> >>>> i'm planning to take this list and put it in a wpf datagrid fot the user >>>> to see. >>>> >>>> Can you assist me with this join operation? >>>> >>>> Thanks, >>>> Zvi >>>> >>>> >>>> On Tue, May 11, 2010 at 2:44 AM, Belvasis >>>> <[email protected]>wrote: >>>> >>>>> Since we are talking about OR/M, a join between two tables usally >>>>> represents a collection property >>>>> of an root entity. So may an Order Entity have a collection of >>>>> OrderItems Entities, the RDMS specifics >>>>> are in the mapping of those classes. >>>>> >>>>> [ActiveRecord("TBL_ORDER")] >>>>> class Order >>>>> { >>>>> [HasMany(typeof(OrderItem), Table="TBL_ORDERITEM", >>>>> ColumnKey="ORDER_ID")] >>>>> public IList OrderItems >>>>> .. >>>>> } >>>>> >>>>> So the list of OrderItems can simply retrieved using >>>>> >>>>> IList pItems = pOrderEntity.OrderItems; >>>>> >>>>> Beside this there are several ways for querys: >>>>> - FindbyPrimaryKey >>>>> - FindAll >>>>> - FindFirst >>>>> - SimplyQuery >>>>> - ScalarQuery >>>>> - ICriteria >>>>> etc. >>>>> >>>>> I don't know if this answers your question, since all of this is good >>>>> described in the documentation. >>>>> >>>>> Regards >>>>> >>>>> 2010/5/10 Zvi Balas <[email protected]> >>>>> >>>>> Hi all, >>>>>> i'm new to AR, >>>>>> >>>>>> I created two table with relation of HasMany between them >>>>>> Now, i want to make a simple fetch that return me s list collection of >>>>>> a join operation between the tables. >>>>>> >>>>>> Can anyone assist me with it? >>>>>> >>>>>> i tried to find help in the documentation/google with no luck. >>>>>> please help me with examples or any other references. >>>>>> >>>>>> Thanks >>>>>> Zvi >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Castle Project Users" group. >>>>>> To post to this group, send email to >>>>>> [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]<castle-project-users%[email protected]> >>>>>> . >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/castle-project-users?hl=en. >>>>>> >>>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Castle Project Users" group. >>>>> To post to this group, send email to >>>>> [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]<castle-project-users%[email protected]> >>>>> . >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/castle-project-users?hl=en. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Castle Project Users" group. >>>> To post to this group, send email to >>>> [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]<castle-project-users%[email protected]> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/castle-project-users?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Castle Project Users" group. >>> To post to this group, send email to >>> [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<castle-project-users%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/castle-project-users?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Castle Project Users" group. >> To post to this group, send email to >> [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<castle-project-users%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/castle-project-users?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To post to this group, send email to [email protected] > . > To unsubscribe from this group, send email to > [email protected]<castle-project-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
