icollection

How to use views in Entity Framework?

☆樱花仙子☆ 提交于 2020-03-04 20:14:51
问题 How can I use database views in Entity Framework? I have the following view in the SQL database called pl SELECT dbo.Product.Productkey, dbo.Product.Productcode, dbo.Product.Productname, dbo.rcode.code, dbo.rcode.label FROM dbo.Product INNER JOIN dbo.rcode ON dbo.Product.programtypekey = dbo.rcode.rcodekey How can I read from the above view in application using EF? Currently I am readinmg from a table as shown below. I want to ready from view instead. In my context, I have public virtual

How to use views in Entity Framework?

柔情痞子 提交于 2020-03-04 20:14:32
问题 How can I use database views in Entity Framework? I have the following view in the SQL database called pl SELECT dbo.Product.Productkey, dbo.Product.Productcode, dbo.Product.Productname, dbo.rcode.code, dbo.rcode.label FROM dbo.Product INNER JOIN dbo.rcode ON dbo.Product.programtypekey = dbo.rcode.rcodekey How can I read from the above view in application using EF? Currently I am readinmg from a table as shown below. I want to ready from view instead. In my context, I have public virtual

thread safe Collection with upper bound

99封情书 提交于 2020-01-24 02:16:28
问题 I am after a collection with the following properties: threadsafe : it will be used in asp.net and multiple clients could try to add, remove and access members concurrently max elements : I want to be able to set an upper bound, a maximum number of elements, at construction time TryAdd : a method that works the same as BlockingCollection<T>.TryAdd(T) would be perfect, i.e. it would return false if the maximum number of elements has been reached Dictionary-like : In most other respects a

F# return ICollection

梦想的初衷 提交于 2020-01-21 08:49:52
问题 I'm working with a library created in C#. I've been working on porting some code to F# but must use quite a few underlying types from the C# lib. One piece of code needs to calculate a list of values and assign it to a public field/property in the class. The field is a C# class that contains two ICollection. My F# code works fine and needs to return an F# Seq/List. I tried the following code snippets which each produce errors. Return type of F# member is a type called recoveryList with type

F# return ICollection

萝らか妹 提交于 2020-01-21 08:48:29
问题 I'm working with a library created in C#. I've been working on porting some code to F# but must use quite a few underlying types from the C# lib. One piece of code needs to calculate a list of values and assign it to a public field/property in the class. The field is a C# class that contains two ICollection. My F# code works fine and needs to return an F# Seq/List. I tried the following code snippets which each produce errors. Return type of F# member is a type called recoveryList with type

What is the advantage of return ICollection over List [duplicate]

元气小坏坏 提交于 2020-01-14 14:15:29
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is the difference between List (of T) and Collection(of T)? I have a static class and a getter to return my List Collection. Now I read and have been told to return ICollection rather than List. What is the advantage of using public static ICollection over public static List? static class Storage { private static List<string> store; static Storage() { store = new List<string>(); } public static ICollection

What is the advantage of return ICollection over List [duplicate]

北城以北 提交于 2020-01-14 14:15:10
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is the difference between List (of T) and Collection(of T)? I have a static class and a getter to return my List Collection. Now I read and have been told to return ICollection rather than List. What is the advantage of using public static ICollection over public static List? static class Storage { private static List<string> store; static Storage() { store = new List<string>(); } public static ICollection

Why can I apply an indexer to an ICollection in VB.Net, but not in C#

安稳与你 提交于 2020-01-11 08:04:44
问题 Was converting some code from VB.Net to C#, when I came across this, in some code using the Ionic Zip library: Dim zipEntry1 As ZipEntry = zipFile1.Entries(0) Simple enough: ZipEntry zipEntry1 = zipFile1.Entries[0]; I get this error on C#: Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.ICollection' Both are using the same version of the DLL, on both zipFile1.Entries is a generic ICollection . I have tested the below on VB.Net, and it builds successfullly:

IList<int> throws Null Reference Exception when adding values

混江龙づ霸主 提交于 2020-01-07 01:59:13
问题 I have a class: public class ClientModelData { public int clientID { get; set; } public IList<int> LocationIDs { get; set; } } When I call it: ClientModelData obj = new ClientModelData(); obj.LocationIDs.Add(1); It throws an exception: `((System.Collections.Generic.ICollection<int>)(client.LocationID))' is null` 回答1: LocationIDs is not initialized therefore it is giving you the error. public IList<int> LocationIDs { get; set; } You should create an instance in the constructor public

Posting Nested Collection to Web API

隐身守侯 提交于 2020-01-03 17:38:46
问题 I'm trying to post a complex type object to web api. On the web api side, when method recieves the object parameter, every property is set properly except a collection that is derived from ICollection. Here is my sample classes: public class MyClass { private int id; public int Id { get { return id; } set { id = value; } } private MyCollection<string> collection; public MyCollection<string> Collection { get { return collection; } set { collection = value; } } } public class MyCollection<T> :