using params[] wih ObjectDataSource [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
My EF insert method is defined as follows:
public void Add(params T[] items)
How can it be used with ObjectDataSource to insert objects?

According to the documentation, the insert method for an ObjectDataSource is designed to call a method that has parameters for each value of the item being inserted, not the item itself (let alone an array of items).
I would either add an overload to your repository that accepts the value for a single item (and perhaps calls Add), or add a mapper somewhere that maps the values to a new item and calls your Add method.

Related

Returning a list of objects from a function to a text file C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a big function that returns a list of objects. I basically need the results to be put in to a text file. The list contains objects of a class with attributes string Index and integer count. I would want it to be written in a textfile like:
Index : Count fe.
BOOK_FROM_STORE : 27
Anybody has some guidance?
Parse the data held by your object to string and then write it to a text file.

What is MAX function? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
var approve = UnitOfWork.Query.Lexis.ApprovedLexis2(DialogService.User.UserID, List.Where(x=>x.Check).Max(x=>x.TxnDate), _batch);
what does line of code returns? can someone explains that? TYIA
List.Where(x=>x.Check).Max(x=>x.TxnDate)
Presumably here List is a list/collection/some IEnumerable<T> for a type T that has (at least) a bool member named Check, and some other member TxnDate (presumably a DateTime of the transaction date).
The Where applies a predicate filter, i.e. it creates a filtered sequence of the items where Check is true. The Max finds the greatest (in terms of x>y, implemented by IComparable[<T>]) of the .TxnDate of each item in the filtered sequence.
So: the expression returns the greatest (last, timewise) transaction date of all the "checked" items in List. If there are no "checked" items, it will throw an exception (you can't ask for the largest of no values; or rather, you can ask, but you won't get a sensible answer).

Searching an object in a collection via lambda and does not return true even if it exist [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
https://www.youtube.com/watch?v=K1xrlc32Tmw&list=PLJUoF2h8Z-brW94dTZ-ZIOhjFq90_lt5K&index=9
4:25 adds a new object in the lineCollection if product does not exist in lineCollection, but at 24:25 it shows duplicating orders? Did i misunderstood how it works?
https://github.com/jedjad/GitHubVS2013
Because the products in duplicate values are not same objects. They may have same names, quantity etc, but initializing a class with same values does not mean that it is the same object as the one initialized before. They are like 2 different apples with same color and size.
If you say that 2 products are same whenever the names are same, then implement IEquatable<Product> in Product class.
public bool Equals(Product other)
{
return Name == other.Name;
}

Getting XtraGrid filter items [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using devexpress XtraGrid. If I filtered this grid using a value related to specific column, I want to get that column(s) and value(s) in c#. Can any body help???
Regards
It looks like you need GridView.ActiveFilter.Criteria property.
It returns CriteriaOperator which is actually expression tree (just because DevExpress gridview filtering can be complex - not by single column).
In your simple case (filtering by one value in one column) you can just convert it to string by .ToString() and then parse string you'll get.
It will be something like [columnName] = columnValue string, and parsing it not a problem.
In complex cases (when it's a real expression tree) you can create your own class having implemented IClientCriteriaVisitor interface and traverse expression tree using CriteriaOperator.Accept method.
See example of such traverse implementation here.

Access part of the list in c# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have this two list here:
List<KeyValuePair<TextBox, KeyValuePair<string, Type>>> textbox1
So, i need that to get the Textbox i need to write:
textbox1.Key
What should i type to get the KeyValuePair<string, Type>> Type, like textbox1.Value.Value?
The type contains string or int.What i need is to access it's value so i can assign an if operator but i don't know how to. Then i need to modify it but that's my next step and i can arrange that myself.
I suppose textbox1.Key won´t compile since textbox1 is a List and therefor does not have any member called Key. Having said this the following may work for you:
textbox[i].Value.Value
Where i is the index of your KV-pair within the list (rather then the actual key)

Categories