Sql Server Built-in Functions, How do I access them? |
![]() ![]() |
Sql Server Built-in Functions, How do I access them? |
Jul 3 2009, 04:21 AM
Post
#1
|
|
|
|
Is there a namespace for SQL server built in functions like getdate()? Is there a way to access these functions? Intellisense doesn't seem to pick up a way to do either.
What about sys.schemas? information_schema.columns? If any of these require a special namespace to access, will the import namespace feature work? I'd really like to be able to have a query ready that dumps the column names, possibly types, lengths, not null information to an output window so that I can create business objects based on the table definition. |
|
|
|
Jul 6 2009, 05:24 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 203 Joined: 15-February 08 From: Perth, Australia Member No.: 90 |
Hi there
There's no way to do this at present. The only way to access a function like getdate() is to map it to a scalar function on SQL Server. > What about sys.schemas? You have to use SQL for this. If you want to bring it into C#-land, change the query type to Program and execute the following: CODE void Main() { ExecuteQuery<SysSchema> ("select * from sys.schemas").Dump(); } class SysSchema { public string Name; public int Schema_ID; public int Principal_ID; } Joe This post has been edited by JoeAlbahari: Jul 6 2009, 05:24 AM |
|
|
|
Jul 24 2009, 05:53 AM
Post
#3
|
|
|
|
Is this a limitiation of linq or linqpad?
|
|
|
|
Jul 24 2009, 07:14 PM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 203 Joined: 15-February 08 From: Perth, Australia Member No.: 90 |
I think it's possible to do these things in LINQ to SQL with manually-created methods and entities.
Try the following: CODE [Function (Name = "GetDate", IsComposable = true)] public DateTime GetDate () { return (DateTime)(this.ExecuteMethodCall (this, ((MethodInfo)(MethodInfo.GetCurrentMethod ()))).ReturnValue); } Joe |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 7th November 2009 - 01:26 PM |