In Windev, is it possible to declare multiple constructors with different scopes? Seems not.
For example:
PROCEDURE CONSTRUCTOR (param1, param2)
...
PROCEDURE PROTECTED CONSTRUCTOR (paramx, paramy, paramz)
...
When I'm trying to do things this way it gives me an error saying that attributes public, protected and private has to be the same between syntaxes of a same procedure.
To add a syntax to an existing procedure: In the project explorer,
select the procedure. Display the popup menu of the procedure and
select "Add a syntax". A new syntax is automatically created in the
code editor.
look at this :
https://doc.windev.com/en-US/?1514063&name=surcharge_prototypemultisyntaxe&1514063&name=surcharge_prototypemultisyntaxe
Hope it helps !
Related
I'm trying to return 2 results from a stored procedure i.e. PageCount and list of rows.
I created the an object:
public class MyData
{
public int PageCount {get;set;}
public ICollection<MyRowObject> Items {get;set;}
}
and I'm calling the following EF code:
var result = this.Database.SqlQuery<T>('EXEC MySP #param1', parameters)
.FirstOrDefault();
But when I run it, it only returns the PageCount and the Items collection which contains the rows is set to null.
The SP is definitely working when executed in SQL as it is returning the PageCount and the list of matching rows.
Any ideas why this is not working on how I can fix this?
Thanks
Please note that I have found various questions on StackOverflow but they are all using a reader and I'm just curious as to whether or not it can be achieved using .SqlQuery.
Update 1:
I don't know if this is achievable but here's a link I thought I'd share as it's a nicely written article but once again, it's using the Reader.
Entity Framework 6 Multiple Result Sets with Stored Procedures
For Return Multiple ResultSet using Entity Framework from Stored Procedure, Please see the below link. I think it's useful for you.
https://www.codeproject.com/Tips/1072284/Return-Multiple-Result-Set-using-Entity-Framework
wherePivotIn is mentionend here (under Filtering Relationships Via Intermediate Table Columns) but I can't find anything about the opposite function.
As the wherePivotIn already exists but not the wherePivotNOTIn, I edited this file : vendor/laravel/framework/src/Illuminate/Database/Eloquant/Relations/BelongsToMany.php
And added this function
public function wherePivotNotIn($column, $values, $boolean = 'and', $not = false)
{
$this->pivotWhereIns[] = func_get_args();
return $this->whereNotIn($this->table.'.'.$column, $values, $boolean, $not);
}
Now the wherePivotNotIn exist and is working. But my question is:
Is it safe to update this file?
In case of update, I guess I will lose this...
After dinging a bit, I found out that the whereIn method accept more than 2 arguments.
We juste have to use it like that to use a "wherePivotNotIn"
->wherePivotIn($column,$value,'and','NotIn')
No need to declare a new class or using scope!
Yeah don't update vendor files that's a no no. Instead , create a class that extends BelongsToMany and put your implementation in there. You'll lose your changes as soon as the file updates.
Never edit what is inside the vendor directory. Create your own method to meet your need, in case it does not exist.
In your case, you can define a Local Query Scope
It will look like:
class Task extends Model
{
public function scopeWherePivotNotIn($query)
{
/**/
}
}
$tasks = Task::wherePivotNotIn()->get();
we have a cleanup hook in our automation framework which tagged from the cucumber feature file
E.g
#cc_task_clean_up_hook_enrol_A
Scenario: Person can enrol_A
When I select the context menu
Then I am able to enroll the patient into 'enrol_A'
the implementation of the hook (#cc_task_clean_up_hook) is
#After(value = "#toc_task_clean_up_hook_enrol_A", order = HookOrder.CLEAN_UP_APP_AFTER)
public void cleanUpTOC() {
this.patientContextPage.selectedContextMenuItem("Pathway");
this.pathWayPage.selectReferences("Enroll in Pathway");
this.pathWayPage.deactivateEnrollment("enrol_A", "Withdrawn");
}
So exactly the same way we need an another scenario like
Scenario: Person can enroll_B
When I select the context menu
Then I am able to enroll the patient into 'enrollB'
So we can implement another hook as follows, the difference is the parameter type "enrollB"
#After(value = "#toc_task_clean_up_hook_enrollB", order = HookOrder.CLEAN_UP_APP_AFTER)
public void cleanUpTOC() {
this.patientContextPage.selectedContextMenuItem("Pathway");
this.pathWayPage.selectReferences("Enroll in Pathway");
this.pathWayPage.deactivateEnrollment("enrol_B", "Withdrawn");
}
So is it possible to consolidate these two methods and write only one generic clean up hook, based on the passed parameter? Your help is much appreciated.
You can add the scenario object to the arguments passed to the after hook. The framework will inject the currently executing scenario to the method.
public void afterMethod(Scenario scenario){}
You can use the getSourceTagNames() method of the Scenario object which will return you the collection of tags for the current executing scenario. From this collection you can determine if you have the tag ending with 'enroll_A' or 'enroll_B'.
Or you can use the getName() method which returns the description of the current scenario. So you will get either 'Person can enroll_A' or 'P..... enroll_B'. Just need to parse again.
You can modify the Then step to pass the enroll type to step definition. Store this in a variable. Use this variable in your after hook. But this will require the after hook to be in the same class.
Also you will need to change the value parameter of After hook to - {"#toc_task_clean_up_hook_enrollA,#toc_task_clean_up_hook_enrollB"}.
One observation that these two seem to have the same steps, if so then have you considered ScenarioOutline instead.
I've got a WCF Data Service setup and can access the table data through the browser url.
Have created a simple Stored Proc which takes in a parameter and then returns some columns from various tables via Joins - how can I consume this?
If you are using an Entity Framework model you could do this:
Open the Model Browser.
Right-click "EntityContainer: (name)"-> "Function Imports" and select "Add Function Import...".
Select stored procedure, specify "Complex" as "Returns a Collection Of", click "Get Column Information" and click "Create New Complex Type".
Add config.SetServiceOperationAccessRule("SomeStoredProcedure", ServiceOperationRights.AllRead); to the InitializeService method in SomeDataService.svc.cs.
Now add a method with the WebGet attribute to SomeDataService.svc.cs that returns an IQueryable of the complex type you defined previously:
[WebGet]
public IQueryable<SomeStoredProcedure_Result> SomeStoredProcedure()
{
return CurrentDataSource.SomeStoredProcedure(1).AsQueryable();
}
The 1 above is a parameter to the stored procedure.
The stored procedure can now be consumed at:
http://localhost/SomeDataService.svc/SomeStoredProcedure
I want to load some data with a SP.
I've put a SP in a Linq to SQL Class and I don't know how to use it for loading it's data in a datagrid.
In LinqToSqlDomainService I can't figure out how to call a SP.
What steps should I use.
Any samples of this ? All samples use a table.
Thank's
This post should hopefully be of help:
http://blogs.msdn.com/brada/archive/2009/08/24/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-24-stored-procedures.aspx
You can create empty view with the same structure of your sproc and map that stored procedure to your function in your DomainService
See sample on http://cid-289eaf995528b9fd.skydrive.live.com/self.aspx/Public/sproc.zip
I found the following excellent step-by-step guide at this site -
http://betaforums.silverlight.net/forums/p/218383/521023.aspx
1) Add a ADO Entity Data Model to your Web project; Select generate from database option; Select your Database instance to connect to.
2) Choose your DB object to import to the Model. You can expand Table node to select any table you want to import to the Model. Expand Stored Procedure node to select your Stored Precedure as well. Click Finish to finish the import.
3) Right click the DB model designer to select Add/Function Import. Give the function a name (same name as your SP would be fine) and select the Stored Procedure you want to map. If your SP returns only one field, you can map the return result to a collection of scalars. If your SP returns more than one field, you could either map the return result to a collection or Entity (if all the field are from a single table) or a collection of Complex types.
If you want to use Complex type, you can click Get Column button to get all the columns for your SP. Then click Create new Complex type button to create this Complex type.
4) Add a Domain Service class to the Web project. Select the DataModel you just created as the DataContext of this Service. Select all the entitis you want expose to the client. The service functions should be generated for those entities.
5) You may not see the Complex type in the Entity list. You have to manully add a query function for your SP in your Service:
Say your SP is called SP1, the Complex type you generated is called SP1_Result.
Add the following code in your Domain Service class:
public IQueryable<SP1_Result> SP1()
{
return this.ObjectContext.SP1().AsQueryable();
}
Now you can compile your project. You might get an error like this: "SP1_Result does not have a Key" (if you not on RIA service SP1 beta). If you do, you need to do the following in the service metadata file:
Added a SP1_Result metadata class and tagged the Key field:
[MetadataTypeAttribute(typeof(SP1_Result.SP1_ResultMetadata))]
public partial class SP1_Result
{
internal sealed class SP1_ResultMetadata
{
[Key]
public int MyId; // Change MyId to the ID field of your SP_Result
}
}
6) Compile your solution. Now you have SP1_Result exposed to the client. Check the generated file, you should see SP1_Result is generated as an Entity class. Now you can access DomainContext.SP1Query and DomainContext.SP1_Results in your Silverlight code. You can treat it as you do with any other Entity(the entity mapped to a table) class.
Calling a stored procedure is trivial. Import it as a function and then invoke the function as a member of the DDS. The return value is an ObservableCollection<> that you can use to set up the DataContext of the object you want to bind.
...unless you want to use it in a Silverlight RIA app via the magic code generated proxy, in which case your goose is cooked unless your result rows exactly match one of the entities. If you can meet that criterion, edit the DomainService class and surface a method that wraps the ObjectContext method.