I have a video unit that has multiple styles,
public class videos {public Int id {get; Set; } // Other areas to be briefed public ILIT & gt; Genre & gt; Styles {get; Set; }} Public Sector Generator {Public Ent ID}; Set; } Public string name {get; Set; } // Skip fields for short}}
Initially I populate video entities and their styles with an XML file that includes all the styles and videos of each genre (a video Different styles can be seen multiple times).
I need to refresh my copy of the video from time to time, and this means that I have to remove all the videos that have not been mapped to a particular genre. During the routine, I will only have a list of video mapping currently, but I do not have to break the link between video and genre, which are not mapped now.
In raw SQL I can say:
Remove from Videogner Generator = @Generic ID and Video ID (@ Video ID List)
Where video ID can be listed "1,2,3,4,5,6"
How can I get the same thing using NHibernate? Should I use HQL or RAW SQL?
An alternate method may be to recover all videos that do not match the VideoDistaltist (I hope this list is almost always empty - the video does not always change the style :)) And then remove the generator from the Zener archive of each video and then update () the style. This method seems like waste trips for DB. Does caching mean only one trip, with any deleted deleted?
How about something like this:
var genreId = 25; Var video = new int [] (1, 2, 3, 4, 5}; Session.CreateQuery ("Remove from video game vg WHERE vg.GenreId =: genreId and vg.videoID is not (video:") .SetParameter ("GenreId", genreId) .SetParameterList ("video", video) .ExecuteUpdate ();
More info.
Comments
Post a Comment