WCF Data Service with EF fails to expose imported functions - entity-framework

(I am also using .NET 4.0 and VS 2010.)
I created a function import returning a complex type, as explained at http://msdn.microsoft.com/en-us/library/bb896231.aspx. The function import and new complex type appear in my .edmx file and in the Designer.cs file. However, the function does not appear when I view the service in the browser, and when I add or update a service reference in the client project, the function does not appear there either - as is to be expected, given the first result.
Creating an imported function and using it seems conceptually very simple and straightforward, and one would think it would just work, as Microsoft's step-by-step instructions appear to suggest: http://msdn.microsoft.com/en-us/library/cc716672.aspx#Y798 (which article shows the SP returning entity types - I tried this also, and it doesn't work for me either).
This blog post shows the addition of a method to the DataService class, which Microsoft's instructions omit: http://www.codegain.com/articles/wcf/miscellaneous/how-to-use-stored-procedure-in-wcf-data-service.aspx I tried adding one method returning a list of entity types and another returning a list of complex types, and still had no success. I still could not access the functions, either directly via the browser or from the client application via a service reference.
Thanks in advance for any help with this.

config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
MS would do well to add a note to the walkthroughs stating that the above bit of code must be there. (It may be better to enable each operation explicitly than to use "*".)
http://www.codegain.com/articles/wcf/miscellaneous/how-to-use-stored-procedure-in-wcf-data-service.aspx shows that line of code. Also, something it is there in the code, commented out, when one creates the WCF Data Service. Some of us like to delete commented-out code that we aren't using and that seems irrelevant - perhaps doing so a bit prematurely, sometimes.

Related

ILE RPG Bind by reference using CRTSQLRPGI

I've been trying a solution for this, but. I cannot find it.
What I'm trying to do, is work with the "bind by reference" ability, but working with ILE RPG written with embedded sql.
I can use the BNDDIR ctl opt in my source. And everything works correctly.
But that means a "bind by copy" method. Checked deleting the SRVPGM and even the BINDDIR. And the caller program still works.
So, is there any way to use "bind by reference" in an ILERPGSQL program?
After my question, an example:
Program SNILOG is a module, that conains several procedures. Part of them, exported.
In QSRVSRC I set the exported procedures, with a source with the same name: SNILOG. Something like this:
STRPGMEXP PGMLVL(*CURRENT)
/************************************************** ******************/
/* *MODULE SNILOG INIGREDI 04/10/21 15:25:30 */
/************************************************** ******************/
EXPORT SYMBOL("GETDIAG_TOSTRING")
EXPORT SYMBOL("GETDIAGNOSTICS")
EXPORT SYMBOL("GRABAR_LOG")
EXPORT SYMBOL("SNILOG")
ENDPGMEXP
As part of the procedures are programmed with embedded sql, the compilation must be done with CRTSQLRPGI, using the parameter OBJTYPE(*SRVPGM).
So, I finally get a SRVPGM called SNILOG, with those 4 procedures exported.
Once I've got the SRVPGM, I add it to a BNDDIR called SNI_BNDDIR.
Ok, let's go to the caller program: SNI600V.
Defined with
dftactgrp(*no)
, of course!.
And compiled with CRTSQLRPGI and parameter OBJTYPE(*PGM).
Here, if I use the control spec
bnddir('SNI_BNDDIR')
, it works fine.
But not fine enough, as this is a "bind by copy" method (I can delete the SRVPGM or the BNDDIR, and it is still working fine).
When I'm not working with SQL, I can use the CRTPGM command, and I can set the BNDSRVPGM parameter, to set the SRVPGM the program is going to be called. Well, just their procedures...
But I cannot find any similar option in CRTSQLRPGI command.
Nor in opt codes in ctl-opt sentence (We have BNDDIR, but not BNDSRVPGM option).
Any idea?
I'm running V7R3M0 with TR level: 6
Thanks in advance!
the use of
bnddir('SNI_BNDDIR')
Is the way to bind by reference OR bind by copy.
The key is what does your BNDDIR look like?
If you want to bind by reference, then it should include *SRVPGM objects.
If you want to bind by copy, then it should include *MODULE objects.
Generally, you want a *BNDDIR for every *SRVPGM that includes the modules (and maybe a utility *SRVPGM or two) needed for building a specific *SRVPGM.
Then one or more *BNDDIR that includes just *SRVPGM objects that are used to build the programs that use those *SRVPGMs.

What types can there be for "UDLText"s other than comments?

I am now using the Caché DB jar to query for class definitions (thanks #daimor; it was an eye opener) and in order to write the source files I need to also account for "UDL texts".
Now, all I have been able to understand of them so far is that they are comments found in the source you actually write in Studio. But then UDLTextDefinition defines .getCategory(); the only value I have seen this method return so far is "comment".
Is there any other possible value?
If you open source code for that class (%Dictionary.UDLTextDefinition), you will find CategoryIsValid method, and will see, that only two values are correct now, and it is comment and error. I'm sure you understand category comment. So, error used when developer managed to save source code with syntax errors in class definition, and that text will be in UDLText and with category error.

tastypie hydrate() not getting called

I am new to tastypie. I have a tastypie model resource where I want to use hydrate() to take serialized data from the client and turn it into a proper format that the data model can use. I have tried hydrate() hydrate_foo() but it seems all the hydrate() functions are not getting called, while dehydrate() will always get called. In my resource model, there're also obj_get(), obj_update(). Are there restrictions/constraints as to how the hydrate() function should be defined in the resource model so that I could use it to manipulate data submitted by the client?
I know this post is pretty old but, since documentation and examples on Tastypie are very limited, I'm adding my small experience here.
Without code it is hard to give a proper answer but I've seen that hydrate methods are only called if we explicitly call in the obj_create function the full_hydrate method as follows:
bundle = self.full_hydrate(bundle)
I thought they were automatically called by Tastypie but it seems not the case.

RequestFactory's Entity Relationships

The details of the Request's with() implementation of RequestFactory in GWT is a bit unclear to me. See here for the official documentation.
Question 1:
When querying the server, RequestFactory does not automatically
populate relations in the object graph. To do this, use the with()
method on a request and specify the related property name as a String.
Does this mean that if the Entity at the server uses Lazy Fetching, the returned EntityProxy will have all the requested objects specified in with()? It seems a bit odd to instantiate the whole object graph of the Object server side, to only send a small piece to the client.
Question 2:
Does req.with("foo").with("foo"); do the same as req.with("foo"); ?
Question 3:
Does req.with("foo").with("bar"); do the same as req.with("foo","bar"); ?
NOTE: I'm having a really hard time finding the implementation details of with() in the source code and the API doesn't help me either.
Question 1:
It probably depends on your server side implemenation.
The with invocation will only make sure that the corresponding getter (getFoo()) is called shortly before the RF call returns to the client.
That's the reason why you also have to make sure to use an OpenSessionInView pattern, otherwise you might run into NullPointeterExceptions.
Question 2:
I guess the Request<T> implements a builder pattern.
The end-result will be the same.
However I am not sure if the getter() will be called twice or if the with method will check if the getter is already requested.
Question 3:
Yes it's the same.
As a sidenote. You can use req.with("foo.bar").
On the backend this will lead to a getFoo().getBar() call.

Autofac configuration problems trying to integrate Quartz

I am working with the Owned type as found here: Strong reference of Autofac 2
I'm also using Quartz scheduler, MSMQ, and EF.
My config looks as follows. I've clearly got something wrong as the context that gets injected to the repositories is a different instance than the one given to the service.
builder.RegisterType<EmailAllocationJob>();
builder.RegisterGeneric(typeof(JobWrapper<>));
builder.RegisterType<DataContext>().InstancePerOwned<EmailAllocationJob>();
builder.RegisterType<DataContext>().As<IUnitOfWork>();
builder.RegisterType<EmailAccountRepository>().As<IEmailAccountRepository>();
builder.RegisterType<EmailMessageRepository>().As<IEmailMessageRepository>();
builder.RegisterType<EmailMessageQueue>().As<IEmailMessageQueue>();
builder.RegisterType<EmailAllocationService>().As<IEmailAllocationService>();
I can't for the life of me figure out how to get the configuration fixed. I'd reckon it's the line:
builder.RegisterType<DataContext>().As<IUnitOfWork>();
What I want to say is something like:
builder.RegisterType<DataContext>().As<IUnitOfWork>().InstancePerOwned<EmailAllocationJob>();
Thanks in advance if you can help.
Ok I got it. Needed the line:
builder.RegisterType<DataContext>().InstancePerOwned<EmailAllocationJob>()
.As<IUnitOfWork>().AsSelf();
So it seems important that the DataContext features as the generic argument to RegisterType ONCE, and that the method calls to As<>() and AsSelf() are to be daisy chained in a single statement. Seems obvious now, with a fresh head following yesterday evening.