Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Extending SQL LINQ Table Class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Olbert - 07 Jan 2008 01:37 GMT
I am trying to extend a table entity class (generated from the visual designer for data contexts) with a property that has no
corresponding column in the underlying Sql Server table.

When I do this, I get a NotSupportedException complaining that the property I added has no supported translation to the database.

The documentation implies that properties not marked with the Column attribute will be ignored when interfacing to the
database...but that's not what appears to be happening.

Is there some other attribute I need to decorate the property with to have the property "skipped"? Or is it just not possible to add
properties to table entity classes using partial classes? If that's the case, the documentation should make that clear.

- Mark
Steven Cheng[MSFT] - 07 Jan 2008 09:11 GMT
Hi Mark,

I think custom properites with partial class for LINQ object class is
supported. As for the property you added, did you by any chance used it in
any data query expression? It seems the custom property will not be
recognized in any query expression to the datasource. Or you just get the
compile error without using the property in any place? here is a web forum
thread mentioned something about add custom property:

#Custom properties in LINQ to SQL classes
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1656614&SiteID=1

and here is a blog article about extending LINQ to SQL query:

#LINQ to SQL (Part 8 - Executing Custom SQL Expressions)
http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executi
ng-custom-sql-expressions.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
   

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: Mark Olbert <ChairmanMAO@newsgroups.nospam>
>Newsgroups: microsoft.public.dotnet.framework
>Subject: Extending SQL LINQ Table Class
>Date: Sun, 06 Jan 2008 17:37:00 -0800

>I am trying to extend a table entity class (generated from the visual designer for data contexts) with a property that has no
>corresponding column in the underlying Sql Server table.
[quoted text clipped - 8 lines]
>
>- Mark
Mark Olbert - 07 Jan 2008 18:33 GMT
Steven,

Thanks for the quick reply. You're right, extended properties work fine so long as you don't try to use them in a query.

I think I saw some references on the web to replacing properties that don't map to database fields to method calls which can be used
in queries.

BTW, the second link you gave me doesn't work.

- Mark

>Hi Mark,
>
[quoted text clipped - 68 lines]
>>
>>- Mark
Steven Cheng[MSFT] - 08 Jan 2008 03:16 GMT
Thanks for your reply Mark,

Do you mean the "LINQ to SQL (Part 8 - Executing Custom SQL Expressions) "
link was broken? If so, you can try searching the subject in web directly.
There are a series of LINQ to SQL articles on ScottGu's blog. They are very
helpful.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

   
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: Mark Olbert <ChairmanMAO@newsgroups.nospam>
>Newsgroups: microsoft.public.dotnet.framework
[quoted text clipped - 84 lines]
>>>
>>>- Mark

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.