wcf - Serialize IEnumerable<T> through the wire? -


I am using a distributed Web application, in which database server SQL Server 2005 database, I have a Microsoft Three Tier Service Application And have installed a web server, where I am using MVP with Monitoring Controller.

On my service layer, the application server, IEnumerable & lt; Country & gt; When I request a list of countries to say, the Service Layer calls the Data Access Contact, which produces such entities:

  public virtual IEnumerable & Lt; T & gt; {DataReader.Read ()) {T entity = this.Fill (dataReader, context) when using FillList (DbCommand command, DataContext context) {(IDataReader dataReader = this.ExecuteReader (command, reference)); Yield returns unit; }}}  

Now I'm a bit worried about the connection of my database because it will remain open when I serialize my controller through WCF. My first question is that what exactly is a concern for my controller to leave serializing the unit by unit when leaving my database connection open? The advantage of this solution is that I can also use a large collection of LNQ (not on LINQ to SQL).

I have come up with this solution: In the service level, I always return a list like:

  public virtual list & lt; T & gt; GetList () {List & lt; T & gt; List = new list & lt; T & gt; (); List.AddRange (this.dataAccess.GetList ())); Return list; }  

But here I am returning the complete list to the controller, and maybe I only need some items from the list. My second question is, is this a good design?

Wait for your suggestions!

I do not see any special problems with the design

Of course, you can T in list ; Do not return the list of all types of behaviors in the objects, and do not return specific types for .net - DataSet and DataTable , for example a bad idea. Use simple sections with properties of primitive types, lists and primitive types, lists and arrays etc. of these simple classes.


Comments

Popular posts from this blog

Post a Jira Comment and set the "viewable by" via Rest API -

asp.net - Getting currently logged in user from AD ( Instead of NT AUTHORITY/NETWORK SERVICE ) -