Reengineer SQL into SubSonic LINQ -


I have 11 records in the menu table, 1 with only one page ID set, though I

 < Code> var test = Menu.All () Where (x = & gt; x.WebPages.Any (pages = & gt; pages.Roles.Contains (roles.GETRolesForUser () [0])  

As I run SQL See 11 records

  SELECT [t0]. [Category ID], [T.]. [Created], [T.]. [Created], [T0]. [ID] [T.]. [ImageID], [T.]. [ImageEdware], [T.]. [Locale], [T.]. [Modified BI], [T.]. [Modified], [ T] [Audi], [T.]. [PageID], [T.]. [Parent ID], [T]. [Title], [T.]. [URL], [T.]. [Visible ] FOR [DBO]. [Menu] AS Where T is present (SELECT NULL FROM [dbo]. [Webpage] AS T1 WHERE ([T1]. [Roles] '%' + 'User' + '%'))  

If I run it, then I get 1 record

  var test = menu. All () where (x => x.WebPages.Any (pages => gt; & gt; ; Pages.Roles. (Rolls. Gatorolforces () [0]) and pages.ID == x.PageID);  

S [class]] [T.]. [Created], [T.]. [Image ID], [T.]. [ImageHouse], [T.]. [Locale], [T.]. [Modified], [T.] [Modified], [T.] [Order id], [t] [[Origin]], [T.] [Title], [T.] [URL], [T.] [Visible] FOr [DBO] [Menu] Where AS T. exists (from selection tap [DPO]. [Web page] AS T1 virus (([T1]. [Roles] '%' + 'user' + '%' like) and ([T1]. [ID] = [T.]. [PageID]))

problem any () until a record in SQL It turns out, no matter what record he will return.

I think that effectively I want to down a union like SQL but I do not know how I From Engineer to C # / Subsonic

 code> m. Where the pidid faucet union is selected m * from the menu, the web page is included in P.ID = m.pageid in P where '% User' % 'Such as P.roll  

I want all the menu records and for those with whom a PageID is set, the user has a role in it regarding the webpage. The user's role is not in the webpage, so I do not want to see it in my results.

Here are my coded sections which generate subsonic

  public partial class menu: IActiveRecord {public int id {get; Set;} Public Ink classID {get; Set;} public bowl visible {get; Set;} public at pageID {received; Set;} public IQueryable & lt; Webpage & gt; Webpage {get {var repo = NorthCadburyWebsite.Models.WebPage.GetRepo (); Return from item in repo. GetAll () where the item Choose ID == _PAGEID item; }}} Public partial class webpage: IActiveRecord {public int id {get; Set;} public string roles {get; Set;}}  

It seems as if you can just add an optional test have to.

  var test = Menu.All () where (x => x.PageID == faucet || x.WebPages. Anyone (pages => pages.Roles.Contains (Roles. GETRolesForUser () [0]) and pages.id == x PageID);  

Edit :

Try to use the method to see if an overlap between roles and roles in DB Is the user?

  var test = Menu.All () Where (x => ft = x.page.name = x.web.pages.no (pages = & gt; pages. Roles difference (roles.gaterolforces (.) Split (',')) and pages .ID == x.PageID));  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -