Ok so I am hoping I can get some help here please?
My situation is that we have three environments 2 are using sql server and 1 is using sql server clustered.
We have a SSIS package that is used to create xml files which works perfectly in environment 1 and 2. However in environment 3 the using clustered sql the xml file generated is out of sequence. It's lists all odd numbered records first then all the even numbered ones.
Everything between the environment is like for like so I cannot see why this is happening.
Are there any steps or an approach I can use to see why this could be happening?
It's lists all odd numbered records first then all the even numbered ones.
Why is that a problem?
Member 13357915 wrote:
so I cannot see why this is happening.
Assuming ordering perhaps. If you are not explicitly ordering the records then you are assuming the ordering. There is no assurance of ordering. It might normally be ordering (default ordering) by the primary index and that might change with a cluster.
Thank you .it has solved partially but still have one problem
If we have rows which are less than or equal for the supplied parameter(Date) we are pulling highest date row here this is working correct .
if we don't have any rows which are less than or equal for the supplied parameter(Date) and if we have rows which are greater than supplied parameter we need to pull lowest date.can you help in this regard
Strange, Could of swore when I first wrote this, I was just getting 1 record.
Then I changed the return value to List from IEnumerable and starting getting 3 records back for each record.
But I doubt that had anything to do with it. I did raise the .Net level to 4.5.2.
Must be my And Statement.
I tried Distinct but It doesn't seen to be working, most likely because I have no clue how use it here.
I started writing in c# and MVC and don't write like this anymore.
Public Shared Function load_COH_ListBox_Info(
ByRef pResults As List(Of cohIndex)) As Integer
Dim pValue As Integer = 0
Dim context As New hx5Context()
From oh In context.Order_History
Where oh.OrderDate >= DbFunctions.AddDays(Today, -40) _
oh.OrderStatus = "COMPLETED" _
Or oh.OrderStatus = "ORDER_CANCELED" _
Or oh.OrderStatus = "ORDER_CANCELED_REFUND_COMPLETE"
Order By oh.OrderNumber Descending
Select New cohIndex With
.orderID = oh.CompletedOrderID,
.orderNumber = oh.OrderNumber,
.orderDate = oh.OrderDate,
.orderStatus = oh.OrderStatus,
.accountName = oh.LoginID,
.total_NetCharge = oh.GrandTotal
pValue = pResults.Count()
I am surprised as to why you didn't consider using GroupBy function? That would be useful in grouping the objects by a property, so that only distinct ones are returned, since they will be grouped by their property in a similar manner, to what you want to expect from Distinct function call here. Something like this,
// Since you said C#from oh in context.Order_History
where oh.OrderDate ...
orderby oh.OrderNumber desc
group oh by oh.RequiredProperty in ohGrouped // RequireProperty is the property you want to use
Something like this will be useful, as it will group the records by the properties which you specify. Please have a look here, [c# - Group by in LINQ - Stack Overflow](https://stackoverflow.com/questions/7325278/group-by-in-linq)
There is a library, which contains a lot of added features to LINQ, you should also look into it as it might also help you out with a lot of good function calls, such as this DistinctBy (DistinctBy takes the properties by which you want to select the records), get it here, GitHub - morelinq/MoreLINQ: Extensions to LINQ to Objects
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~