c# - Linq to SQL Associated Table Not Accessible -


i reworking application had working code in it. necessity, i'm moving several commonly-used bits separate project. 1 of linq sql model.

i have references resolved , namespaces corrected compiles correctly except couple of areas code using mapping association access different table.

so example,

    template t = db.templates.firstordefault( f => f.templateid == templateid );     list<item> templatelist = new list<item>( );     foreach ( var r in globalitems )     {         if (t.templatechildren.firstordefault( f => f.itemid == r.itemid ) != null )             // stuff...     } 

in instance, cannot access t..templatechildren. compiler tells me inaccessible due protection level.

taking @ linq sql designer code, find problem:

        [global::system.data.linq.mapping.associationattribute(name="template_templatechildren", storage="_templatechildren", thiskey="templateid", otherkey="templateid")]     internal entityset<templatechildren> templatechildren     {                 {             return this._templatechildren;         }         set         {             this._templatechildren.assign(value);         }     } 

notice entityset has been decorated "internal". if change "public", code compiles fine. of course, change model break again because tool-generated code.

this worked when model in same project code thatt's calling it, , i've checked , double-checked set public in model itself, yet code generator insists on making mapping internal.

anyone have thoughts why works way, or how can trick code generator making public?

answered own question:

open model , click on relationship arrow that's being problematic. in properties pane, expand either "child property" or "parent property" needed , change access modifier.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -