oeoren / apirio Goto Github PK
View Code? Open in Web Editor NEWCreate a WebApi from SQL Server Stored Procedures
License: Apache License 2.0
Create a WebApi from SQL Server Stored Procedures
License: Apache License 2.0
ALTER PROC [dbo].[API_Login_Get]
(
@Mobile BIGINT ,
@password VARCHAR(50) ,
@deviceid VARCHAR(256) ,
@DeviceName VARCHAR(256) ,
@Manufacturer VARCHAR(256) ,
@ModelName VARCHAR(256) ,
@AndroidVersion VARCHAR(10) ,
@AppVersionCode VARCHAR(10)
)
Having BIGINT parameter returns the following error "Message": "An error has occurred.", "ExceptionMessage": "Procedure or function 'API_Login_Get' expects parameter '@Mobile', which was not supplied.",
When running the project, the code fails to build and throws the following exception in APiAssemblyResolver.cs:
System.Exception
HResult=0x80131500
Message=Unknown SQL Datatype: Byte
Source=NTIAPI
StackTrace:
at NTIAPI.App_Start.ApirAssemblyResolver.GetAssemblies() in C:\Users\nti\source\repos\NTIAPI\App_Start\ApirAssemblyResolver.cs:line 40
at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)
at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)
at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache()
at System.Lazy`1.CreateValue()
I believe that it might be down to usage of the SQL column type 'TinyInt' which doesn't seem to be mapped in TypeMapper.cs. Any chance of a fix and updated package?
The table structure in question looks like:
[dbo].[cms6_Content](
[ContentID] [int] IDENTITY(150,1) NOT NULL,
[ContentName] [varchar](100) NULL,
[PageTitle] [varchar](100) NULL,
[PageDescription] [varchar](240) NULL,
[PageKeywords] [varchar](180) NULL,
[PageContent] [ntext] NULL,
[GroupPermissions] [smallint] NULL,
[SiteID] [smallint] NULL,
[ContentTypeID] [int] NULL,
[DateAdded] [datetime] NULL,
[HeaderID] [int] NULL,
[RHmenuID] [int] NULL,
[RHmenu2ID] [int] NULL,
[RHmenu3ID] [int] NULL,
[LHmenuID] [int] NULL,
[LHmenu2ID] [int] NULL,
[LHmenu3ID] [int] NULL,
[FooterID] [int] NULL,
[SubnavID] [int] NULL,
[Subnav2ID] [int] NULL,
[URLoptimize] [varchar](350) NULL,
[ContentDateModified] [datetime] NULL,
[Util_01] [varchar](50) NULL,
[Util_02] [varchar](50) NULL,
[Util_03] [varchar](50) NULL,
[Util_04] [varchar](50) NULL,
[Util_05] [varchar](50) NULL,
[Util_06] [varchar](50) NULL,
[Util_07] [varchar](50) NULL,
[Util_08] [varchar](50) NULL,
[Util_09] [varchar](50) NULL,
[MenuWidth] [int] NULL,
[NewsThumb] [varchar](100) NULL,
[Picasa] [varchar](250) NULL,
[Tags] [varchar](1000) NULL,
[TagsOperator] [tinyint] NULL,
[IncludeNews] [bit] NULL,
[IncludeNotice] [bit] NULL,
[IsCategory] [bit] NULL,
[ParentCategory] [int] NULL,
[ParentPage] [int] NULL,
[ParentPageLast] [int] NULL,
[ParentPageLast1] [int] NULL,
[VideoUrl] [varchar](100) NULL,
[Comments] [tinyint] NULL,
[CommentsCount] [int] NULL,
[HasGallery] [tinyint] NULL,
[ContentOrder] [int] NULL,
[ExtraStyles] [varchar](max) NULL,
[Redirect] [varchar](200) NULL,
[Activate] [tinyint] NULL,
[ExpiryDate] [datetime] NULL,
[UrlName] [varchar](100) NULL,
[URLoptimize2] [varchar](350) NULL,
[RunFile] [varchar](50) NULL,
[PostIsListing] [tinyint] NULL,
[AllowedGroups] [varchar](150) NULL,
[RHmenu4ID] [int] NULL,
[RHmenu5ID] [int] NULL,
[RHmenu6ID] [int] NULL,
[DctFld] [varchar](max) NULL,
[AdminID] [int] NULL,
Hi,
While trying this Project withing Asp.Net Application.
we tried Creating Stored Procedure with two parameters but in such case it throws Compile error.
but keeping one parameter project builds. Can you please highlight something about this
Hi. is there any tech support for this tool.
i used it once in a project. it worked once tje first time but in after i was unable to make it work. i keep getting compile exception error. thx for the help
If Stored Procedure is returning more than 1 recordset then the JSON output should be returned like below :
{
"status": "success",
"RS1": [{
"Company": "DATALIGENCE INFOTECH PVT. LTD.",
"URL": "http://103.209.67.249/EmployeeAPIWebService/EmployeeServiceAPI.asmx",
"Website": "http://www.data-ligence.com/img/Logo1.png",
"Footer": "Copyright © 2016 - 2020 | DATALIGENCE INFOTECH PVT. LTD.",
"AboutUsURL": "http://www.data-ligence.com/about.html"
}, {
"Company": "99 Corporates",
"URL": "http://103.209.67.249/EmployeeAPIWebService/EmployeeServiceAPI.asmx",
"Website": "http://www.99corporates.com/",
"Footer": "Copyright © 2016 - 2020 | PYRAMID CONSULTANTS PVT. LTD.",
"AboutUsURL": "http://www.data-ligence.com/about.html"
}],
"RS2": [{
"Name": "ABC",
}, {
"Name": "XYZ",
}],
"message": null
}
Hi
I'm testing this for the first time following the instructions from your post on Code Project. When starting debugging I get the message below, the App_Data remains empty (No swaError file).
When removing the datetime2(0) parameters from my stored procedures it seems to work correctly.
Server Error in '/' Application.
Unknown SQL Datatype: datetime2
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Unknown SQL Datatype: datetime2
First of all it's a great tool. I am using the executable file as a windows service and it's working very much fine.
But when I installed it as a package using "nuget" to my project directory using Visual Studio(version 2013).
I am getting build exception as follows :
Error 2 The type or namespace name 'ApirLib' could not be found (are you missing a using directive or an assembly reference?) \ApirAssemblyResolver.cs 1 7 RestWebService
Error 1 The type or namespace name 'Apir' could not be found (are you missing a using directive or an assembly reference?) \App_Start\ApirConfig.cs 1 7 RestWebService
Error 3 The type or namespace name 'ApirLib' could not be found (are you missing a using directive or an assembly reference?) \App_Start\ApirConfig.cs 2 7 RestWebService
Consider me as a NOOB if you find question a silly one?
Dear Oeoren,
Would you have an update for the .Net core framework. As most folks will be moving to the core platform now.
Thank you for all the hard work. I was thinking of building something on the same lines however wanted to have the controllers in the DB. Essentially capture the get/Post etc. requests and pass this into a proc. The proc to handle passing this to a relevant controller which would be other proc(s).
Thus one could define a table of possible procs which would act as controllers and subsequently call other procs for the business logic if needed. I seem to be alone on this thought as I do not fine anything on the net. The closest is what you have done.
Any ideas for and against.
Thanks again for all the work done. Very impressive!
This is a fantastic tool for CRUD and Restful integration and provides a great base for developing a fully isolated Restful interface to a DB; eliminating the DAL. But, can you include the ability to develop the CRUD and interfaces for the indexes? Selecting data is commonly done by selecting by an indexed field directly or as part of a wild-card search. This method would require passing a parameter to develop the CRUD "Get" calls either using a full index value or by selecting with a value containing "%".. Can this be done? I also loaded the install version (MSI) and that tool would also be very useful if Index "Get" was included... I would be happy to do the effort for both.....
regards
rick
Stored Procedures having output parameter should be added in the JSON Output
Most of my stored procedures return a message as OUTPUT which also should be part of the JSON output
@message VARCHAR(100)=NULL OUT
The @message parameter is used for :
SET @message = 'User Id does not exist.'
SET @message = 'User Id is disabled.'
SET @message = 'Incorrect Password.' etc...
Hi this is a great project.
Several of our senior developers are good with business rules and SQL, but zero C#. Using this API we can create a bridge SQL > Front End (angular, ionic, etc.) without problems.
In our case we have stored procedures that have parameters of Table Types. Do you think to add support to this feature?
Regards
Is it possible to authenticate against Azure Active Directory to access an Azure SQL database with this tool?
Hi @oeoren
first of all: let me thank you for your awesome work. Your project kinda saved me a lot of time.
I would ask you for one change, so I dont have to change your idea:
The Codegenerator allways uses the dbo schema to generate endpoints. Can you make it generating dynamic endpoints? In some projects we got different schemas for our sps.
Best wishes
Christoph
Hi testing out apirIO (which really looks great).
But when I want to generate the stored procs I get: "Specified cast is not valid"
The simple table created (in the DATA schema)
CREATE TABLE [DATA].[BusinessAreas] ( [BusinessAreaId] INT NOT NULL IDENTITY(1,1), [BusinessArea] VARCHAR(15) NOT NULL, [isActive] BIT NOT NULL DEFAULT 1, CONSTRAINT [PK_BusinessAreas] PRIMARY KEY ([BusinessAreaId]) )
The command used and output I get:
C:\apir>apir sqlgen -table:BusinessAreas -resource:BusinessArea -alter:true Specified cast is not valid.
I am migrating some existing stored procedures to use an API, but when I try to compile the new API procedures, I get an error when using #TEMP tables. Do I just need to switch to a regular table variable and drop it when I'm finished? Or is there a way to work with #TEMP tables in ApirIO?
Exception thrown: 'System.Data.SqlClient.SqlException' in ApirLib.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in SqlWebApi.dll
An exception of type 'System.Data.SqlClient.SqlException' occurred in SqlWebApi.dll but was not handled in user code
Invalid object name '#TEMP'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.